Question: help in c++ Write a program that reads in the rainfall for each of 12 months and outputs the month and the rainfall for the
help in c++
Write a program that reads in the rainfall for each of 12 months and outputs the month and the rainfall for the month. It should then output the month with the most rainfall, the month with the least rainfall, the total amount of rainfall for the year, and the average monthly rainfall. All rainfall amounts should be output with 2 significant digits after the decimal point. - The program should incorporate two parallel arrays: month of type string containing the month names, and rainfall of type double containing the rainfall in inches for the corresponding month. Hint: Check slides 8 thru 10 of CS1336_Lect7c_Arrays_Compare_Paral/el.pptx for examples. - The program should read in the rainfall amount for each month using a for loop. Do not accept negative numbers for rainfall amount. - The program should output the month right justified in a field width of 10 and the corresponding rainfall right justified in a field width of 6. - The program should calculate the highest and lowest amounts of rainfall and display the amounts and the corresponding month names. It should also output the index of the highest and lowest rainfall amounts. Hint 1: Check slides 3 and 4 of CS1336_Lect7c_Arrays_Compare_Parallel.pptx for the code to find the lowest and the highest. Hint 2: In addition, you will have to keep track of the index at which you found the highest and the lowest amount. Output the month name corresponding to the index. For example, if rainfall [3] is the lowest rainfall, you will print month [3] as the corresponding month. - The program should calculate and display the total rainfall for the year and the average monthly rainfall. Hint: Make use of an accumulator in your loop. - Validation: Do not accept negative numbers for monthly rainfall figures. I will be grading this lab with a script. If you do not use parallel arrays and do not find and use the index of the lowest and index of the highest, you will NOT receive credit. I will change your grade in Blackboard to reflect this. When the input is as shown in Figure 1, your program should produce the output as shown in Figure 2. Figure 1: (input)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
