Question

376 Chapter 6 Loop Structures Case Programming Assignments con Most Rainfall in the USA USE CASE DEFINITION e Windows application opens with the heading Most Rainfall in US - Kauai, a ListBox object that displays the monthly rainfall amounts, an i amounts in inches mage, and a Button object that allows the user to begin entering their rainfall 2. A menu bar displays the File menu, which has two menu items: Clear and Exit. 3. T ofnintel emo he user enters up to 12 monthly values of rainfall per month in Kauai. 12 monthly value in an Inpur Box object, with each valuc representing the number of inches 4. The program asks the user for the rainfall amount again if the value is a negative number or the entry is a 5. The program displays the average inches of rainfall rounded to one decimal place nonnumeric value. he user can clear the input and the result by clicking the Clear menu item, and then can repeat Steps 3-5. If the user dlicks the Cancel button in the input box, the average for the values entered is calculated. If the user did not enter any values, the program displays an appropriate message 7. The user clicks the Exit menu item to close the application. FIGURE 6-115 Most Rainfall in US File Most Rainfall in US - Kauai 8.6 9.2 10.5 14.2 Rainfall Average Enter Rainfall 6.4 3.2 2.9 5.9 8.8 9.2 7.4 Average Rainfall per Month is 8.0 inches

media%2Fc13%2Fc132284b-66a8-4d18-8a1a-d0

media%2Fe49%2Fe4936771-d238-43f4-a12e-46

media%2Fe49%2Fe4936771-d238-43f4-a12e-46

the code is in visual basic

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the solution:

code:

Public Class frmMain
    'declare variable
    Dim avg As Double
    Dim sum As Double = 0
    Dim rain As Double
    Dim count As Integer
    Private Sub ClearToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClearToolStripMenuItem.Click
        'clear all the values
        txtRainfall.Text = ""
        lstRainfall.Items.Clear()
        sum = 0
        avg = 0
    End Sub

    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close() 'close form
    End Sub

    'textbox button press event
    Private Sub textBox_EnterClicked(sender As Object, e As KeyEventArgs) Handles txtRainfall.KeyDown
        count = lstRainfall.Items.Count()
        If e.KeyCode = Keys.Enter Then 'check for enter key press
            If Not Double.TryParse(txtRainfall.Text, rain) Then
                MessageBox.Show("Error! Enter Rainfall") ''error when enter wrong data
            Else
                lstRainfall.Items.Add(txtRainfall.Text) ''add the rainfall
                txtRainfall.Text = ""
                If count = 11 Then 'sum of all the raifall entered
                    For i = 0 To lstRainfall.Items.Count - 1
                        sum += CDbl(lstRainfall.Items(i))
                    Next
                    avg = sum / lstRainfall.Items.Count 'average the sum of all the rainfall entered
                    lblRainfall.Text = "Avearge Rainfall per month is " & FormatNumber(avg, 1) & " inches " 'display number in one decimal format place
                End If
            End If
        End If
    End Sub

End Class

output:

We were unable to transcribe this image

Add a comment
Know the answer?
Add Answer to:
the code is in visual basic 376 Chapter 6 Loop Structures Case Programming Assignments con Most...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • One example of computer-aided design (CAD) is building geometric structures inter- actively. In Chapter 4, we...

    One example of computer-aided design (CAD) is building geometric structures inter- actively. In Chapter 4, we will look at ways in which we can model geometric objects comprised of polygons. Here, we want to examine the interactive part. Let’s start by writing an application that will let the user specify a series of axis- aligned rectangles interactively. Each rectangle can be defined by two mouse positions at diagonally opposite corners. Consider the event listener canvas.addEventListener("mousedown", function() { gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer); if...

  • Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue....

    Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue. You will need to think about the differences in the Stack and Queue. Think about how they operate and how the nodes may differ.   Modify the code as necessary. You will need to push to the Stack, pop from the Stack, peek at the Stack. You will need a member functions like in the example code. Your program will need to show that everything...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT