loops and decisions

i have an example output but i am stuck right now and i dont know how to get certain things to add up in a loop to gets sums in a summary this is the sample output and what i have so far is below the sample.


Enter the product number of the item sold: 1250
Enter the number of items sold: 3
Enter the price for one of the items: 19.99

Enter the product number of the item sold: 2820
Enter the number of items sold: 5
Enter the price for one of the items: 12.50

Enter the product number of the item sold: 3124
Enter the number of items sold: 7
Enter the price for one of the items: 20.30

Enter the product number of the item sold: 987
Enter the number of items sold: 2
Enter the price for one of the items: 10.11

Enter the product number of the item sold: 123
Enter the number of items sold: 36
Enter the price for one of the items: 1.50

Enter the product number of the item sold: 4567
Enter the number of items sold: 9
Enter the price for one of the items: 4.56

Enter the product number of the item sold: 1433
Enter the number of items sold: 20
Enter the price for one of the items: 4.50

Enter the product number of the item sold: 3748
Enter the number of items sold: 1
Enter the price for one of the items: 1.99

Enter the product number of the item sold: 3967
Enter the number of items sold: 5
Enter the price for one of the items: 7.10

Enter the product number of the item sold: 1130
Enter the number of items sold: 30
Enter the price for one of the items: 19.77

Enter the product number of the item sold: 303
Enter the number of items sold: 7
Enter the price for one of the items: 2.00

Enter the product number of the item sold: 530
Enter the number of items sold: 65
Enter the price for one of the items: 0.80

Enter the product number of the item sold: 916
Enter the number of items sold: 130
Enter the price for one of the items: 1.23

Enter the product number of the item sold: 1111
Enter the number of items sold: 75
Enter the price for one of the items: 1.72

Enter the product number of the item sold: 2222
Enter the number of items sold: 7
Enter the price for one of the items: 9.46

Enter the product number of the item sold: 3333
Enter the number of items sold: 4
Enter the price for one of the items: 24.00

Enter the product number of the item sold: 999
Enter the number of items sold: 31
Enter the price for one of the items: 0.90

Enter the product number of the item sold: 7531
Enter the number of items sold: 17
Enter the price for one of the items: 4.10

Enter the product number of the item sold: -1


***** Product Sales Summary *****

Gizmo Count: 271
Gizmo Sales Total: 328.02

Widget Count: 128
Widget Sales Total: 872.07

Doohickey Count: 12
Doohickey Sales Total: 128.72

Thingamajig Count: 17
Thingamajig Sales Total: 275.59

Invalid Sales: 2















#include <iostream>
#include <iomanip>

using namespace std;

int main()


const int GIZMO_LOWER = 0;
const int GIZMO_UPPER = 999;
const int WIDGETS_LOWER = 1000;
const int WIDGETS_UPPER = 1999;
const int DOOHICKEYS_LOWER = 2000;
const int DOOHICKEYS_UPPER = 2999;
const int THINGAMAJIGS_LOWER = 3000;
const int THINGAMAJIGS_UPPER = 3999;


string product_type

double gizmo;
double widget;
double thingamajig;
double doohickey;
double invalid;

double product_number;
double items_sold;
double price;
double giz_count;
double wid_count;
double doo_count;
double thing_count;
double giz_totat;
double wid_total;
double doo_total;
double thing_total;


while (product_number = -1)
{
cout << "enter the product number of the item sold:";
cin >> product_number



if ( product_number >= GIZMO_LOWER && productNum <= GIZMO_UPPER )
product_type = gizmo;
else if (product_number >= WIDGETS_LOWER && <= WIDGETS_UPPER)
product_type = widget;
else if (product_number >= DOOHICKEYS_LOWER && <= DOOHICKEYS_UPPER)
product_type = doohickey;
else if (product_number >= THINGAMAJIGS_LOWER && <= THINGAMAJIGS_UPPER)
product_type = thingamajig;
else if (product_number > 3999)
product_type = invalid;


cout << "enter the number of items sold: ";
cin >> items_sold;

cout << "Enter the price for each of the items: ";
cin >> price;

Topic archived. No new replies allowed.