Program which calculates a company's total sales for a 3-month period for each region?

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.
On line 19 you need to remove the semicolon. Furthermore it's 3 not 4
Also you need to embed the lines that belongs to the for loop into curly braces (before line 20 and after line 22)
1
2
3
4
5
6
7
8
9
10
11
12
13
      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;
		}

		totalsales = totalsales + rsales;
		rsales = 0;		
	  }
Now i have this code:



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
32
33
//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 < 3; m = m + 1)
		{
			cout << "Enter monthly sales: ";
			cin >> sales;
			rsales = sales + rsales;
			cout << "The region's total monthly sales: " << rsales << endl;
		}

		totalsales = totalsales + rsales;
		rsales = 0;	
		}
	
	cout << "The total monthly sales is: " << totalsales << endl;
	  return 0;
}	//end of main function 


the total and region are right is right but is there any way for the region total to display after getting three inputs(each month) for each region? Right now i have this:


Enter monthly sales: 1
The region's total monthly sales: 1
Enter monthly sales: 1
The region's total monthly sales: 2
Enter monthly sales: 1
The region's total monthly sales: 3
Enter monthly sales: 1
The region's total monthly sales: 1
Enter monthly sales: 1
The region's total monthly sales: 2
Enter monthly sales: 1
The region's total monthly sales: 3
Enter monthly sales: 1
The region's total monthly sales: 1
Enter monthly sales: 1
The region's total monthly sales: 2
Enter monthly sales: 1
The region's total monthly sales: 3
Enter monthly sales: 1
The region's total monthly sales: 1
Enter monthly sales: 1
The region's total monthly sales: 2
Enter monthly sales: 1
The region's total monthly sales: 3
The total monthly sales is: 12
Press any key to continue . . .


I guess that you want to take line 24 out of the inner for loop (so move line 24 after the closing brace)
Topic archived. No new replies allowed.