PDA

View Full Version : ...................c++?


nowuknow2002
10-12-2007, 04:38 AM
How would I create a program that that displays the sum of a sales amount in each of 4 regions, during a 3 month period, which would also display the sum? …Nothing fancy. I am a beginner and want to be able to understand the code…Pls…

I need to loop it …this is what I have but I am terrible wrong I am sure. There has to be a way off not adding all the regions? I commented out some of the region.


include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{ double sales = 0.0;
double totalSales = 0.0;
int region = 0;
const int Nregion = 1;
const int Sregion = 2;
const int Eregion = 3;
const int Wregion = 4;
while (region < 4)
{
cout<< "Enter first sale amount for North region " << Nregion << " : " ;
cin >> sales;
//cout<< "Enter first sale amount for South region " << Sregion << " : " ;
//cin >> sales;
{
totalSales = totalSales + sales;

// cout<< "Enter next sale amount region " << region << " :" ;
//cin >> sales;
}
cout << "Region" << region << "sales: "

<< totalSales << endl;

region = region + 1;

totalSales = 0.0;

Return 0;
}

junglejungle
10-12-2007, 04:39 AM
were you taught about structures / multi dimensional arrays ;-)

thats a hint...

I'm not gonna do ya homework for ya.