total counter

I'm working with a simple do, if, else, while loop. At the end I'm trying to include a total amount counter for all of the sales in a category. I know how to do a counter with one at a time but adding more than one at a time has been whipping my butt. here is the code:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
string damageType;
float OriginalSalesPrice, discAmount, finalSalesPrice, originalPricetotal=0, disctotalAmount=0;
int slightDamageTotal=0, MajorDamageTotal=0, code;
char resp;

do
{
cout << left << setprecision(2) << fixed;
cout << setw(30) << "Please enter original price ";
cin >> setw(30) >> OriginalSalesPrice;
cout << setw(30) << "Please enter damage code \n"
"1. Slight Damage \n"
"2. Major Damage \n";
cin >> setw(30) >> code;

if
(code==1)
{
damageType="Slight Damage";
discAmount=OriginalSalesPrice*.10;
slightDamageTotal=slightDamageTotal+1;
}
else
if
(code==2)
{
damageType="Major Damage";
discAmount=OriginalSalesPrice*.50;
MajorDamageTotal=MajorDamageTotal+1;
}
finalSalesPrice=OriginalSalesPrice-discAmount;

cout << setw(30) << "Original Price " << OriginalSalesPrice <<'\n';
cout << setw(30) << "Damage Description " << damageType <<'\n';
cout << setw(30) << "Discount Amount " << discAmount <<'\n';
cout << setw(30) << "Sales Price " << finalSalesPrice <<'\n';//add assignment for this above
cout << setw(30) << "More data y/n ?" <<'\n';
cin >> resp;
}
while (resp=='y');


originalPricetotal=OriginalSalesPrice+OriginalSalesPrice;
disctotalAmount=discAmount+discAmount;

cout << setw(30)<<"# of slightly damaged items sold"<< slightDamageTotal << '\n';
cout << setw(30) << "# of major damage items sold" << MajorDamageTotal << '\n';
cout << setw(30) << "Total original price" << originalPricetotal << '\n';
cout << setw(30) << "Total discount amount" << disctotalAmount << '\n';
return 0;
}
Topic archived. No new replies allowed.