Price: $20 USD

Question description

Type your programming question here...

I need help creating this program, I have the GUI all setup however I am newer to VB and do not know where to start in order to do this


Write a Visual Basicicon1.png program named TemperatureData that stores daily high temperatures for a certain (customizable) number of days. The TemperatureData program should also provide buttons that, when clicked, display the coldest (minimum), warmest (maximum), or average temperature stored in the program. Read on for additional information.

GUI design

Your GUI should be similar to the following image:

Sample GUI for Homework 5. Top: "New temperature:", a text box, and an Add button. Left: ListBox shows temperatures. Right: "Find Coldest", "Find Warmest", "Find Average", and "Clear All" buttons.

Suggested control names are:

Top row: newTempLabel / newTempTextBox / addButton
Left side: tempsListLabel / tempsListBox
Right side: coldestButton / warmestButton / averageButton / clearAllButton


Set the AcceptButton property of the Form to addButton, so that the Add button is triggered by default when the Enter key is pressed.
Set the Text property of the Form to "Temperature Dataicon1.png".
No other changes to any controls' properties are needed right now. You will make some changes in your codeicon1.png later.

Instance variables and constant

Your program must start by declaring a constant and two instance variables outside any other method in the program:

A constant of type Integer that indicates the largest number of temperatures that can be stored in the program. Suggested name: MAX_NUM_TEMPS.
An array of type Double that stores the actual temperatures entered by the user. The array elements should be numbered from 0 to (MAX_NUM_TEMPS - 1). Suggested name: temperatures or temps.
A variable of type Integer that stores the actual number of temperatures stored in the array. Based on this value, you can find the location of the next empty element in the array (and, similarly, the last element used). Suggested name: numTemps.
You will use these throughout your program.

Add button

When the Add button is clicked, the following actions should occur:

If newTempTextBox is not empty (i.e., its text is not equal to String.Empty), then:
Store the contents of newTempTextBox (converted to a number) into a variable.
Store this value into the next empty element of your temperatures array and into a new item in tempsListBox.
Add 1 to numTemps.
If the maximum number of temperatures has been read, then disable newTempTextBox and addButton (by changing their Enabled properties).
Find Coldest button

When the Find Coldest button is clicked, your program should search the temperatures array for the coldest (i.e., lowest) temperature. Use MessageBox.Show to display the coldest temperature. The MessageBox should look similar to the following:

MessageBox with message "The coldest temperature is 17 degrees", title "Coldest Temperature", Information icon, and OK button.

Note that some array elements may not contain data yet. Because we only want to consider valid temperatures, not meaningless zeroes (0's), do not use a For Each-Next loop for this button. Use a standard For-Next loop instead. In the loop, count up to the number of temperatures entered (numTemps - 1), not the loop's upper bound.

The findSmallestButton_Click method on page 256 of your textbook is a good example of how to do this. However, do not simply copy and paste that code! Adapt it to fit what you need to do here.

Find Warmest button

When the Find Warmest button is clicked, your program should search the temperatures array for the warmest (i.e., highest) temperature. Use MessageBox.Show to display the warmest temperature.

This method should be very similar to your method for the Find Coldest button. The MessageBox used to show the result should be the same, except you should write "warmest" instead of "coldest". Once again, use a standard For-Next loop, not a For Each-Next loop. In the loop, count up to the number of temperatures entered (numTemps - 1), not the loop's upper bound.

Find Average button

When the Find Average button is clicked, first check whether any temperatures have been entered (to avoid dividing by zero). If no temperatures were entered, show the following MessageBox and do nothing else in this method:

A MessageBox. Message: "No temperatures entered yet!". Title: "Error". Buttons: OK. Icon: Error.

Otherwise, your program should add up all temperatures stored in the array, then divide by the number of temperatures entered to find the average. Display the average in a MessageBox similar to the one for the Find Coldest and Find Warmest buttons.

Use a For Each-Next loop to add the temperatures. In this method, the unused array elements have the value 0, so they have no effect on the average.

Clear All button

When the Clear All button is clicked:

Reset every element of the temperatures array to 0 (using a For Each-Next loop).
Reset the numTemps counter variable to 0.
Clear all items from the list box.
Enable newTempTextBox and the AddButton, if needed.

Tutor Answer

(Top Tutor) Daniel C.
School: UC Berkeley
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1829 tutors are online

Related Programming questions


Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors