So i need to write a program for school that displays a company's 3-month total sales for 4 different regions, North, South, West, and East. Each regions total sales for 3 months must also be displayed. I have to use this data: Region 1: 1000, 2000, 2000, Region 2: 2000, 3000, 6000, Region 3: 2000, 4000, 2000, and Region 4: 9000, 2000, 2000, Arrays cannot be used, and two for statements with one being nested must be used.
I'm not sure how do this; i started it off like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
//companysales.cpp-displays a company's total sales
#include <iostream>
using std::endl;
using std::cout;
using std::cin;
int main()
{
//declare variables
int sales = 0;
int totalsales = 0;
int rsales = 0;
//get input
for (int r = 0; r < 4; r = r + 1)
{
for (int m = 0; m < 4; m = m + 1);
cout << "Enter monthly sales: ";
cin >> sales;
rsales = sales + rsales;
cout << "The region's total monthly sales: " << rsales << endl;
int rsales = 0;
int sales = 0;
}
totalsales = totalsales + rsales;
cout << "The total monthly sales is: " << totalsales << endl;
return 0;
} //end of main function
|
with this code i don't get what i am supposed to have in the output:
Enter monthly sales: 2
The region's total monthly sales: 2
Enter monthly sales: 3
The region's total monthly sales: 5
Enter monthly sales: 5
The region's total monthly sales: 10
Enter monthly sales: 1
The region's total monthly sales: 11
The total monthly sales is: 11
Press any key to continue . . . |
I can't get the Enter monthly sales to display three times per each region, and the total sales for each region does not add up correctly. Please help.