repitition struc. Question

I am stumped on how to code a program in a book i have. The program also should display the total sales made during the three months. Complete the program by entering c++ code that allows the user to enter four sets(one set for each region ) of three sales amounts(one sales amount for each month). The program should display each regions total sales for the three month period, and the companys total sales for the three month period.

im not sure how to use do while or for loops to do it.
Last edited on
To start:
As there are 4 area and we need 3 sales for each area, we could use a
4x3 array, where each row represents an area and each of the 3 columns for each row represets the monthly sales .
1
2
3
const int areas = 4;
const int numSales = 3;
double areaSales[areas][numSales] = {0};


As we know exactly how much data we need - we can use a for loop, to loop through each row (area) and use cin to get the 3 values for each row (monthly sales)

Last edited on
is there like a simple way to do it withour using arrays? i havent learned them yet and they arent in the chapter im on
Yes, but it looks messy. If you absolutely cannot use arrays, you can make variables like area1month1, area1month2, etc. However, I do not see how you would use a while and/or for loop if it is not an array...
Topic archived. No new replies allowed.