Thank you. With your help, this is what I came up with.
My problem now is that I can't get the subtotals to add up. and my total revenue won't work.
Any suggestions?
Code:
#include <iostream>
#include <iomanip>
using namespace std;
#define STARBUCKS 1.00
#define TOGOS 1.50
#define CHIPOTLE 2.00
int main()
{
int yes_no,
id_number,
qty_sb,
qty_tg,
qty_chi,
tot_sb = 0,
tot_tg = 0,
tot_chi = 0,
tot_qty,
i,
k = 0;
char type_card;
double sub_total,
sb_subtotal,
tg_subtotal,
chi_subtotal,
tot_sbprofit,
tot_tgprofit,
tot_chiprofit,
total,
profit_total=0;
cout << "Do you have a student sale to enter? (1=yes, 0=no)? ";
cin >> yes_no;
while (yes_no == 1)
{
id_number = k;
cout << "\nPlease enter the student ID number:\t\t\t\t" << fixed << setw(8);
cin >> id_number;
cout << "Please enter the type of card sold\n";
cout << "(S for Starbucks, T or Togo's, and C for Chipotle):\t\t" << fixed << setw(8);
cin >> type_card;
switch (type_card)
{
case 'S':
case 's':
cout << "Please enter number of cards sold:\t\t\t\t" << fixed << setw(8);
cin >> qty_sb;
sb_subtotal = qty_sb * STARBUCKS;
cout << "\nStudent " << id_number << " raised the following amount for the school:" << fixed << setprecision(2) << setw(12) << sb_subtotal << "\n"; break;
case 'T':
case 't':
cout << "Please enter number of cards sold:\t\t\t\t" << fixed << setw(8);
cin >> qty_tg;
tg_subtotal = qty_tg * TOGOS;
cout << "\nStudent " << id_number << " raised the following amount for the school:" << fixed << setprecision(2) << setw(12) << tg_subtotal << "\n"; break;
case 'C':
case 'c':
cout << "Please enter number of cards sold:\t\t\t\t" << fixed << setw(8);
cin >> qty_chi;
chi_subtotal = qty_chi * CHIPOTLE;
cout << "\nStudent " << id_number << " raised the following amount for the school:" << fixed << setprecision(2) << setw(12) << chi_subtotal << "\n"; break;
}
k++ ;
cout << "Do you have a student sale to enter? (1=yes, 0=no)? ";
cin >> yes_no;
}
if (k != 0)
{
cout << "\n**********************End of Run Report*******************";
cout << "\nTotal number of starbucks gift cards sold\t" << qty_sb;
cout << "\nTotal number of Togo's gift cards sold\t" << qty_tg;
cout << "\nTotal number of Chipotle gift cards sold\t" << qty_chi;
cout << "\nTotal number of all gift cards sold\t" << tot_qty;
cout << "\nTotal revenue from Starbucks gift cards\t" << tot_sbprofit;
cout << "\nTotal revenue from Togo's gift cards\t" << tot_tgprofit;
cout << "\nTotal revenue from Chipotle gift cards\t" << tot_chiprofit;
cout << "\nTotal revenue raised\t\t" << profit_total;
for (i = 0; i < k; i++)
{
tot_sb += qty_sb;
tot_tg += qty_tg;
tot_chi += qty_chi;
total += sb_subtotal + tg_subtotal + chi_subtotal;
profit_total += total;
}
return 0;
}
}