Ok everything is working for me on this project besides when I try to input how many gb of data I went over this is the error I am getting once I run my program.
Here is my code, I think my project is complete besides figuring this step out I have no idea why it's not working. Thank you in advance for any help guys, I always am using your site for information and this is my first question!
Below is my code
#include<iostream>
#include<iomanip> using namespace std;
int main() { int numPhones; double extraData, billTotal, phoneTotal,
dataTotal = 0, eDataTotal, taxTotal, roundedEData;//extra totals to
add them together at the end for total bill char dataPlan; const
double tax = .1025; const int phoneCost = 20;
cout << "How many phones are on your plan?"; cin >> numPhones;
cout << "1. 1GB=$20" << endl;//the menu cout << "2. 3GB=$45" <<
endl; cout << "3. 6GB=$60" << endl; cout << "Which data plan do you
have(Use 1-3)?"; dataPlan = cin.get();
cin.ignore();
cout << "How much extra data have you used?"; cin >> extraData;
phoneTotal = numPhones * phoneCost;
if (dataPlan == '1')//deciphering what the user choose in the menu {
dataTotal = 20; } else if (dataPlan == '2') { dataTotal = 45;
} else if (dataPlan == '3') { dataTotal = 60; } else { cout
<< "Please restart and enter a valid value."; } // switch
(dataPlan) { case '1':dataPlan = 20; break; case '2':dataPlan =
45; break; case '3':dataPlan = 60; break; default:cout <<
"Please restart and enter a valid value."; break; }
roundedEData = ceil(extraData);//rounding the extra data amount if
(roundedEData == 0) { eDataTotal = 0; } else { roundedEData -=
1; //In order to account for the higher price in the first gig of
extra data eDataTotal = 15 + (roundedEData * 10); }
billTotal = eDataTotal + dataTotal + phoneTotal;
taxTotal = billTotal*tax; billTotal += taxTotal;
cout << "\n----------Cell Phone Final Bill------------\n";//Beginning
of final output cout << fixed << setprecision(2); cout << setw(20)
<< "Phone Charge:" << "$" << setw(10) << phoneTotal << endl; cout <<
setw(20) << "Data Charge:" << "$" << setw(10) << dataTotal << endl;
cout << setw(20) << "Extra Data Charge:" << "$" << setw(10) <<
eDataTotal << endl; cout << setw(20) << "Tax:" << "$" << setw(10) <<
taxTotal << endl; cout << setw(20) << "Total:" << "$" << setw(10) <<
billTotal << endl;
system("pause"); return 0;
}
Aucun commentaire:
Enregistrer un commentaire