Question: Please code with c++ This week we're learning about C++ arrays , which are a simple type of data structure. Arrays are a way of

Please code with c++

This week we're learning about C++ arrays, which are a simple type of data structure. Arrays are a way of representing a series or a list of values, rather than just the single-value variables that we've used so far. They are "structured" in the sense that they hold one or more data values together and individual values can be accessed with a subscript or index, which is an integer value referencing a place in the array. Arrays always start at index 0, so an array of 10 elements has 0 - 9 as valid indices.

Assignment

Using values stored in arrays, write a program that does the following:

1) Prompts the user (in a loop) to enter rainfall totals (in inches) for each of 10 locations:

Eureka Ukiah Redding Sacramento Santa Rosa Oakland San Francisco Livermore Mountain View San Jose

Validate the input so the rainfall must be re-entered if it is less than zero or greater than 100.

2) Using 3 value-returning functions, calculate the locations with the highest and lowest rainfall and the average rainfall across the 10 cities.

3) Output the 3 calculated values with a precision of 2 digits past the decimal point.

Example Input/Output

A run of your program should look like this (with the user-input values in bold):

Enter the rainfall total for Eureka: 26.08 Enter the rainfall total for Ukiah: 25.54 Enter the rainfall total for Redding: 25.30 Enter the rainfall total for Sacramento: 14.77 Enter the rainfall total for Santa Rosa:26.73 Enter the rainfall total for Oakland: 13.96 Enter the rainfall total for San Francisco: 17.47 Enter the rainfall total for Livermore: 11.40 Enter the rainfall total for Mountain View: -12 Rainfall must be greater than 0 or less than 100. Please re-enter: 9.75 Enter the rainfall total for San Jose: 26.08 The city with the highest rainfall is Santa Rosa. The city with the lowest rainfall is Mountain View. The average rainfall across all cities is 19.71 inches.

Starter File

The file posted in this week's module -- main.cpp -- provides a starter main() function along with an array of locations and suggested prototypes for the value-returning functions. You do not have to start with this file or use the same function names -- these are provided only as a reference to help you get started.

What to Submit

Submit a screenshot of one run through your program and your source code (.cpp file). Your screenshot should include the input (and re-entering) of at least one invalid value (i.e. below 0 or greater than 100). If you would like to use some real rainfall totals, this page (Links to an external site.)Links to an external site.has some of the latest numbers (we've had good amount of rain this year!) or you can just use any floating point values you wish.

PreviousNext

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!