I need help with this programming exercise: Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should display a list of the months and their corresponding rainfall values sorted in order by rainfall amount, from highest to lowest.

Question
Asked Oct 11, 2019
192 views

I need help with this programming exercise:

 

Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should display a list of the months and their corresponding rainfall values sorted in order by rainfall amount, from highest to lowest.

check_circle

Expert Answer

Step 1

Before solving this problem our first duty is to understand what question is asking:

  • Here user wants to calculate the rainfall statistics of 1year.
  • Enter the value of the rainfall of the individual month.
  • User also wants to check whether the value entered is greater than 0 or not.
  • If the entered value is less than 0, an error message should be display that “The Value you entered is should be greater than zero.”
  • Also Sort it to the ordered by the rainfall from highest to lowest.
  • Finally display the list of rainfall in their respective corresponding rainfall.

For solving this problem some variables are used to define the months, total rainfall and average rain fall. Also, some data types are used to declare the variables. To check the condition is rainfall greater than 0 a loop is required and for sorting the rainfalls in a highest to lowest. setw function is used to set the width with count.

Step 2

Following are the list of Variables, Data type and the functions is used in the programs:

1. Variables: i, j, temp, rainfall, months, rain.

2. Data type: Integer, Double...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Explain in at least a paragraph what are considered pervasive security infrastructure risks

A: Pervasive security infrastructure refers to cloud security risks. As many users possibly from differ...

question_answer

Q: in python 3.2 Selling a new vehicle pays a salesperson $1500. Selling a used vehicle pays a commissi...

A: Import local function to use currency formatting in the program.prompt user to enter the type of veh...

question_answer

Q: The following data fragment occurs in the middle of a data stream for which the byte-stuffing algori...

A: Byte stuffing algorithm, also referred as Character stuffing algorithm was invented to overcome the ...

question_answer

Q: c. Outline an algorithm for finding the largest key in a B-tree.

A: B-tree is a data structure tree that sorts the data, allows insertion and deletion, searching, and s...

question_answer

Q: Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarc...

A: The fully labelled Crow's Foot ERD using a specialization hierarchy is given below. The ERD containU...

question_answer

Q: Hello good afternoon,   Write a C++ program that reads data from an input file, takes the data and c...

A: Program designcreate two functions for printing name, and computing and printing graderead data from...

question_answer

Q: I need this for my programming lab. It’s python.   Given three String Variables that have Been given...

A: String in python are arrays of bytes representing Unicode characters. however, Python does not have ...

question_answer

Q: Question 4: What does the following code output? vector icecream ( 10, "Vanilla" ); icecream.insert...

A: The complete source code for the given question is given below along with the output.Note: If the he...

question_answer

Q: What is the most important thing to help with introduction to computers?

A: The most important thing in introduction to computers are,Hardware andSoftware