Include Iostream

Include Iostream

<p>#include <iostream> using namespace std; int main () { float restBill; char qualityOfService; float tip; float totalBill;</p><p>//input restaurant bill cout << "Enter restaurant bill, negative to quit" << endl; cin >> restBill; while (restBill >= 0) { //input quality of service cout << "How was your service?" << endl; cout <<"Enter P for poor, A for Average, and E for Excellent" << endl; cin >> qualityOfService;</p><p>//calculate tip if (qualityOfService == 'P' || qualityOfService == 'p') tip = .10 * restBill; else if (qualityOfService == 'A' || qualityOfService == 'a') tip = .15 * restBill; else if (qualityOfService == 'E' || qualityOfService == 'e') tip = .20 * restBill; else tip = .15 * restBill;</p><p>//calculate total bill totalBill = restBill + tip; cout << "total bill is "<< totalBill;</p><p>//input restaurant bill cout << "Enter restaurant bill, negative to quit" << endl; cin >> restBill; } return 0; } #include <iostream> using namespace std; void InputRestBill(float& restBill); void InputQualityOfService(char& qualityOfService); float Tip(char qualityOfService,float restBill); void CalcFinalBill(float restBill, float tip, float& totalBill); int main () { float restBill; char qualityOfService; float tip; float totalBill;</p><p>InputRestBill(restBill); while (restBill >= 0) { InputQualityOfService(qualityOfService); tip = Tip(qualityOfService,restBill); CalcFinalBill(restBill, tip, totalBill); cout <<"Total Bill is " << totalBill << endl; InputRestBill(restBill); } return 0; } //********************** //input restaurant bill //************************** void InputRestBill(float& restBill) {</p><p> cout << "Enter restaurant bill, negative to quit" << endl; cin >> restBill;</p><p>} //************************* //input quality of service //*************************** void InputQualityOfService(char& qualityOfService) {</p><p> cout << "How was your service?" << endl; cout <<"Enter P for poor, A for Average, and E for Excellent" << endl; cin >> qualityOfService; } //************* //calculate tip //************************* float Tip(char qualityOfService,float restBill) { float tip; if (qualityOfService == 'P' || qualityOfService == 'p') tip = (float).10 * restBill; else if (qualityOfService == 'A' || qualityOfService == 'a') tip = (float).15 * restBill; else if (qualityOfService == 'E' || qualityOfService == 'e') tip = (float).20 * restBill; else tip = (float).15 * restBill;</p><p> return tip; } //********************************* //calculate total bill //************************************** void CalcFinalBill(float restBill, float tip, float& totalBill) {</p><p> totalBill = restBill + tip; cout << "total bill is "<< totalBill; }</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us