Create a program that displays the sum of the sales amounts made in each of four regions (North, South, East, West) during a three month period. The program should display the total sales made during the three months.
1. Complete the program by entering the 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 region's total sales for the 3-month period, and the company's total sales for the 3-month period.
-You must use some type of loop to receive credit for the exercise....can not use arrays
What I have so far.....
1. Complete the program by entering the 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 region's total sales for the 3-month period, and the company's total sales for the 3-month period.
-You must use some type of loop to receive credit for the exercise....can not use arrays
What I have so far.....
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
char region = ' ';
int monthlySales1 = 0;
int monthlySales2 = 0;
int monthlySales3 = 0;
int totalSales = 0;
int totalRegSales = 0;
cout << "Enter region (N/S/E/W): ";
cin >> region;
do
{
// Get Monthly sales...
cout << "First monthly sales amount for Region " << region << ": ";
cin >> monthlySales1;
cout << "Next monthly sales amount for Region " << region << ": ";
cin >> monthlySales2;
cout << "Next monthly sales amount for Region " << region << ": ";
cin >> monthlySales3;
// Add our regional sales
totalRegSales = monthlySales1 + monthlySales2 + monthlySales3;
// Display the sales made for that region....
cout << "Total sales for Region " << region << ": " << totalRegSales << "\n\n";
totalSales += totalRegSales;
// And if our total sales is more than 0, then display it before
// asking for our next region.
if( totalSales > 0 ){
cout << "\nTotal Sales at this point: " << totalSales << "\n\n";
}
cout << "Enter region (N/S/E/W): ";
cin >> region;
}
while (region == 'N' || region == 'S' || region == 'E' || region == 'W');
return 0;
}
Comment