Write a program that:

create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December).
The list is: 15.5, 12, 9.9, 4.67, 3.75, 0.6, 0, 0.32, 1.2, 2.9, 8.6, 12.7
the program should calculate and display the:
total rainfall for the year;
the average monthly rainfall;
the months with the highest amount.
the months with the lowest amount.
You need to figure out how to access each element in the list,
You need to add the all up to find the total;
You need to also divide by the length of your list to get the average;
Use the min() and the max() functions to find the highest and lowest amounts.
There is a video that talks about the min and max functions.
Print out statements showing the 4 required outputs
(replace the ?? with amounts that are calculate by your code or months as appropriate)

The total rainfall for the year: ?? inches
The average rainfall per month is: ?? inches
The month with the lowest rainfall is ?? with ?? inches
The month with the most rainfall is ?? with ?? inches

Respuesta :

Answer:

mark me brainlist

Explanation:

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

int main ()

{

const int MONTHS = 12;

string name[MONTHS]= {"January","February","March","April","May","June","July","August","September","October","November","December"};

int count= 0;

double rain[MONTHS];

double avg;

double year=0;

double highest;

string highMonth;

double lowest;

string lowMonth;

for(count = 0; count < MONTHS; count++) // ask user to enter amount of rainfall for each month

{

cout <<"How many inches of rain does "<< name[count];

cout<< " have? \n";

cin >> rain[count];

while (rain[count] < 0)

{

cout << "Please enter a number greater than 0."<< endl;

cin >> rain[count];

}

}

for(int count=0; count<MONTHS; count++) // totals up all the rainfall

year += rain[count];

avg = year / MONTHS;

for( int count = 0; count < MONTHS; count++) //spits out each month with its amount of rain

{

cout << name[count];

cout<< " has ";

cout<< rain[count] << " inches of rainfall.\n";

}

highest = rain[0]; // finds month with the highest amount of rain

for (count = 1 ;count < MONTHS; count++)

{

if (rain[count] > highest)

{

highMonth = name[count];

highest = rain[count];

}

}

lowest = rain[0]; // finds month with the least amount of rain

for (count = 1 ;count < MONTHS; count++)

{

if (rain[count] < lowest)

{

lowMonth = name[count];

lowest = rain[count];

}

}

cout << endl;

cout << setprecision(2) << fixed;

cout <<"Total Rainfall throughout the year is " <<year << " inches" << endl;

cout <<"The average monthly rainfall is " << avg << " inches"<< endl;

cout <<"The month with the highest amount of rainfall is " << highMonth << " with " << highest<< " inches."<< endl;

cout <<"The month with the lowest amount of rainfall is " << lowMonth << " with " << lowest<< " inches."<< endl;

return 0;

}

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE