I would like the user to be able to see the sales total for any given month when they input a valid month. Everything works other than what I stated above. I am completely stumped on how to store the salesTotal values inputted by the user into an array (monthSalesTotal). Here is what i have so far, any help will be greatly appreciated.
#include <iostream>
using namespace std;
int main()
{
int i;
int salesTotal[12];
double average = 0.0;
double sum = 0.0;
int choice;
int monthSalesTotal[12];
for (i = 1; i < 13; i++)
{
cout << "Please enter the monthly sales total for month " << i << ":> ";
cin >> salesTotal[i];
sum += salesTotal[i];
average = sum / i;
}
cout << "The average monthly sales for the year is:> " << average << endl;
cout << "For what month would you like to see a sales value? ";
cin >> choice;
switch(choice)
{
case 1:
choice = 1;
break;
case 2:
choice = 2;
break;
case 3:
choice = 3;
break;
case 4:
choice = 4;
break;
case 5:
choice = 5;
break;
case 6:
choice = 6;
break;
case 7:
choice = 7;
break;
case 8:
choice = 8;
break;
case 9:
choice = 9;
break;
case 10:
choice = 10;
break;
case 11:
choice = 11;
break;
case 12:
choice = 12;
break;
default:
cout << "This is an invaid choice, please re-enter:> ";
cin >> choice;
}
cout << "The sales total for the month " << choice << " is:> " << salesTotal[i] << endl;
system("pause");
return 0;
}