Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I keep getting this output and not 1-12. #include <iostream> #include <iomanip>

ID: 3649077 • Letter: I

Question

I keep getting this output and not 1-12.

#include <iostream>

#include <iomanip>

using namespace std;


int main()

{

const int Months = 12;

int rain;

int values[Months];

double total = 0;

double avg;

int largest, monthlarge;

int smallest, monthsmall, count;


char names_months[Months] = {1,2,3,4,5,6,7,8,9,10,11,12};


for (int i = 0; i < Months; i++)

{

cout << "Enter the total rainfall for " << names_months[i]<<":";

cin >> rain;


if (rain < 0)

{

cout << "Do no accept negative numbers!" << endl;

cout << "Please enter a postive number." << endl;

cin >> rain;

}


values[i] = rain;

total += rain;

}


cout << "The total rainfall for the year is "<< total << endl;


avg = total / (double)Months;

cout << "The average amount of rainfall is " << avg << endl;


for ( int month = 1; month <=Months; month ++)

{

largest = values[0];

//Find largest

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

{

if (values[count] > largest)

{

largest = values[count];

monthlarge = count;

}

}

smallest = values[0];

//Find smallest

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

{

if ( values[count] < smallest )

{

smallest = values[count];

monthsmall = count;

}

}

}

//Disply the hightest and lowest rainfall

cout << "The hightest month value is : " << names_months[monthlarge] << endl;

cout << "The lowest month value is : " << names_months[monthsmall] << endl;


return 0;


Explanation / Answer

The numbers variable used in the array has not been defined. You need to define numbers as a const int numbers = 12; or used #define numbers 12