I am back again with another problem. Hope someone can help. I can get the program to run, but I cannot figure out how to end the program when sales < than 0 for each section.
The problem is this:
Create a program that displays the sum of the sales amounts made in each of four regtions (North, East, South, and West) during a 3 month period. The program also should display the total sales made during the three months. The C++ code should allow the user to enter 4 sets (one set for each region) of 3 sales amounts (one sales amount for each month). The program should display each region's total sales for the 3-month period, and the company's total sales for the 3-month period.
Use the following four sets of data to test the program:
2000, 4000, 3000
2000, 5000, 5000
3000, 2000, 1000
4000, 1000, 6000
Here is my program so far:
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
int northRegionSales = 0;
int totalNorthSales = 0;
int northRegion = 1;
int eastRegionSales = 0;
int totalEastSales = 0;
int eastRegion = 1;
int southRegionSales = 0;
int totalSouthSales = 0;
int southRegion = 1;
int westRegionSales = 0;
int totalWestSales = 0;
int westRegion = 1;
int totalSales = 0;
//enter sales amounts for North region
cout << "Sales amount for North region (negative number to stop): $ ";
cin >> northRegionSales;
do
{
northRegion += 1;
totalNorthSales = totalNorthSales + northRegionSales;
cout << "Next sales amount for North region (negative number to stop): $ ";
cin >> northRegionSales;
} while (northRegion <= 2);
cout << endl;
totalNorthSales = totalNorthSales + northRegionSales;
//enter sales amounts for East region
cout << "Sales amount for East region (negative number to stop): $ ";
cin >> eastRegionSales;
do
{
eastRegion += 1;
totalEastSales = totalEastSales + eastRegionSales;
cout << "Next sales amount for East region (negative number to stop): $ ";
cin >> eastRegionSales;
} while (eastRegion <= 2);
cout << endl;
totalEastSales = totalEastSales + eastRegionSales;
//enter sales amounts for South region
cout << "Sales amount for South region (negative number to stop): $ ";
cin >> southRegionSales;
do
{
southRegion += 1;
totalSouthSales = totalSouthSales + southRegionSales;
cout << "Next sales amount for South region (negative number to stop): $ ";
cin >> southRegionSales;
} while (southRegion <= 2);
cout << endl;
totalSouthSales = totalSouthSales + southRegionSales;
//enter sales amounts for West region
cout << "Sales amount for West region (negative number to stop): $ ";
cin >> westRegionSales;
do
{
westRegion += 1;
totalWestSales = totalWestSales + westRegionSales;
cout << "Next sales amount for South region (negative number to stop): $ ";
cin >> westRegionSales;
} while (westRegion <= 2);
cout << endl;
totalWestSales = totalWestSales + westRegionSales;
// end do while
//display total sales for each region
cout << "Total sales for North region: $ " << totalNorthSales << endl;
cout << "Total sales for East region: $ " << totalEastSales << endl;
cout << "Total sales for South region: $ " << totalSouthSales << endl;
cout << "Total sales for West region: $ " << totalWestSales << endl;
totalSales = totalNorthSales + totalEastSales + totalSouthSales + totalWestSales;
cout << "Total sales: $ " << totalSales << endl;
return 0;
} //end of main function




