I'm having a problem with getting the right calculation for the subtotal of each ticket. I'm currently getting this type of result:
Premium Tickets: $ 80.00 x 2 = $ 5242800
Regular Tickets: $ 40.00 x 2 = $ 40
Sales Tax (9.25): $484962.72
What am I doing wrong? C++ code:
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
cout << setprecision(2) << fixed << showpoint;
const float SALES_TAX = 0.0925;
float premiumTicket = 80;
float regularTicket = 40;
int premTicket;
int regTicket;
premTotal = premiumTicket * premTicket;
regTotal = regularTicket * regTicket;
float subTotal = premTotal + regTotal;
float tax = subTotal * SALES_TAX;
float total = subTotal + tax;
cout << "How many Premium Tickets? ($80): " << setw(4) << endl;
cin >> premTicket;
cout << "How many Regular Tickets? ($40): " << setw(4) << endl;
cin >> regTicket;
cout << "Premium Tickets: " << setw(4) << " $ " << setw(4) << premiumTicket << " x " << premTicket << " = " << setw(4) << " $ " << setw(4) << premTotal << endl;
cout << "Regular Tickets: " << setw(4) << " $ " << setw(4) << regularTicket << " x " << regTicket << " = " << setw(4) << " $ " << setw(4) << regTotal << endl;
cout << "Sales Tax (9.25): $" << setw(4) << tax << endl;
return 0;
}