198k views
3 votes
Design a program that asks the user to enter a store's sales for each day of the week. The amounts should be stored in an array. Use a loop to calculate the total sales for the week and display the result. cpp

1 Answer

1 vote

Answer:

#include <iostream>

using namespace std;

int main()

{

int storeSales [7];

//Receiving user input

for(int i = 0; i<7; i++){

cout<<"Enter the sales"<< endl;

cin>>storeSales[i];

}

//calculating and printing the total

int total = 0;

for(int i = 0; i<7; i++){

total = total + storeSales[i];

}

cout << "The total is: " <<total<< endl;

return 0;

}

Step-by-step explanation:

  • Using C++ programming language
  • Create an array of size seven (Since there are seven days in a week)
  • Use a for loop to add up elements to the arrays when user is prompt
  • use a second for loop to calculate the total of the element added
  • Outside the second for loop, print the total
User Brianz
by
6.0k points