Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you guys help me with the output I think is wrong?? #include <iostream> #inc

ID: 3911513 • Letter: C

Question

Can you guys help me with the output I think is wrong??

#include <iostream>

#include <iomanip>

#include "Tips.h";

using namespace std;

int main()

{

     double totalBillAmount, tipAmount,tipRate,taxR;

     cout << "Gratuity Calculator.... ";

     cout << "Enter the tax rate:";

     cin >> taxR;

     Tips calTips(taxR);

     char ch = 'Y';

     do

     {

          cout << " Enter total Bill amount: ";

          cin >> totalBillAmount;

          cout << " Enter the tip rate: ";

          cin >> tipRate;

          if (totalBillAmount < 0 || tipRate < 0)

               cout << "Invalid input try again...";

          else

          {

               tipAmount = calTips.getTip(totalBillAmount, tipRate);

               double total_amount= totalBillAmount + tipAmount+taxR;

               cout << "The tip on the bill amount " << totalBillAmount << " with tiprate " << tipRate << " is: " << tipAmount << endl;

               cout << " Total Amount is: " << total_amount;

               cout << " Do you want process another bill... ";

               cout << " Enter 'Y' to continue or any key to stop: ";

               cin >> ch;

          }

     } while (ch == 'Y' || ch == 'y');

     return 0;

}

Tips.cpp:

#include "Tips.h"

#include <iostream>

using namespace std;

double Tips::getTip(double tbAmt, double tRate)

{

     mealCost = tbAmt + (tbAmt * taxRate);

     mealCost = tbAmt * (1 + taxRate);

     tbAmt = mealCost / (1 + taxRate);

     tipAmount = tbAmt * tRate;

    

     return tipAmount;

}

tips.h:

class Tips

{

     public:

          double taxRate;

          double mealCost;

          double tipRate;

          double tipAmount;

    

          Tips(double rate) {

               if (rate<0)

                     taxRate = .065;

               else {

                     taxRate = rate;

               }

          }

          double getTip(double bill, double tip);

};

Explanation / Answer

#include <iostream>

#include <iomanip>

#include "Tips.h";

using namespace std;

int main()

{

double totalBillAmount, tipAmount,tipRate,taxR;

cout << "Gratuity Calculator.... ";

cout << "Enter the tax rate:";

cin >> taxR;

Tips calTips(taxR);

char ch = 'Y';

do

{

cout << " Enter total Bill amount: ";

cin >> totalBillAmount;

cout << " Enter the tip rate: ";

cin >> tipRate;

if (totalBillAmount < 0 || tipRate < 0)

cout << "Invalid input try again...";

else

{

tipAmount = calTips.getTip(totalBillAmount, tipRate);

double total_amount= totalBillAmount + tipAmount+calTips.getTip(totalBillAmount, taxR);

cout << "The tip on the bill amount " << totalBillAmount << " with tiprate " << tipRate << " is: " << tipAmount << endl;

cout << " Total Amount is: " << total_amount;

cout << " Do you want process another bill... ";

cout << " Enter 'Y' to continue or any key to stop: ";

cin >> ch;

}

} while (ch == 'Y' || ch == 'y');

return 0;

}

Tips.cpp

#include "Tips.h"

#include <iostream>

using namespace std;

double Tips::getTip(double tbAmt, double tRate)

{

mealCost = tbAmt + (tbAmt * taxRate/100.0);

//mealCost = tbAmt * (1 + taxRate/100.0);

//tbAmt = mealCost / (1 + taxRate/100.0);

tipAmount = tbAmt * tRate/100.0;

return tipAmount;

}

Tips.h

class Tips

{

public:

double taxRate;

double mealCost;

double tipRate;

double tipAmount;

Tips(double rate) {

if (rate<0)

taxRate = 10;

else {

taxRate = rate;

}

}

double getTip(double bill, double tip);

};

Output:-