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

During the tax season, every Friday, the J&J accounting firm provides assistance

ID: 3715041 • Letter: D

Question

During the tax season, every Friday, the J&J accounting firm provides assistance to people who prepare their own tax returns. Their charges are as follows: If a person has low income (<= 25,000) and the consulting time is less than or equal to 30 minutes, there are no charges; otherwise, the service charges are 40% of the regular hourly rate for the time over 30 minutes. For others, if the consulting time is less than or equal to 20 minutes, there are no service charges; otherwise, service charges are 70% of the regular hourly rate for the time over 20 minutes. (For example, suppose that a person has low income and spent 1 hour and 15 minutes, and the hourly rate is $70.00. Then the billing amount is 70.00 * 0.40 * (45 / 60) = $21.00.) Write a program that prompts the user to enter the hourly rate, the total consulting time, and whether the person has low income. The program should output the billing amount. Your program must contain a function that takes as input the hourly rate, the total consulting time, and a value indicating whether the person has low income. The function should return the billing amount. Your program may prompt the user to enter the consulting time in minutes.

CODE

*** PLEASE FILL IN CODE UNDER THE COMMENTS INSIDE OF THE TEMPLATE CODE ***

#include <iostream>
#include <iomanip>

using namespace std;

// declare billingAmount function

int main()
{
double hourlyRate;
double consultingTime;
bool lowIncome;
double yearlyIncome;

cout << fixed << showpoint << setprecision(2);

cout << "Enter yearly income: ";
cin >> yearlyIncome;
cout << endl;

// set lowIncome

cout << "Enter the hourly rate: ";
cin >> hourlyRate;
cout << endl;

cout << "Enter consulting time in minutes: ";
cin >> consultingTime;
cout << endl;

// call billingAmount

return 0;
}

double billingAmount(double hRate, double consTime, bool lowInc)
{
// write your billingAmmount function here
}

Explanation / Answer

I have completed your code. Declared the billingAmount method and then defined it as per the given set of rules and regulations. If you have any doubts, drop a comment. Thanks.

//code.cpp

#include <iostream>

#include <iomanip>

using namespace std;

// declare billingAmount function

double billingAmount(double,double,bool);

int main()

{

    double hourlyRate;

    double consultingTime;

    bool lowIncome;

    double yearlyIncome;

    cout << fixed << showpoint << setprecision(2);

    cout << "Enter yearly income: ";

    cin >> yearlyIncome;

    cout << endl;

    // set lowIncome

    cout << "Enter the hourly rate: ";

    cin >> hourlyRate;

    cout << endl;

    cout << "Enter consulting time in minutes: ";

    cin >> consultingTime;

    cout << endl;

   

                if(yearlyIncome<=25000){

                                lowIncome=true;            

                }else{

                                lowIncome=false;

                }

                // calling billingAmount

                double amount=billingAmount(hourlyRate,consultingTime,lowIncome);

                cout<<"Bill amount: $"<<amount<<endl;

  

return 0;

}

//method to calculate the bill amount

double billingAmount(double hRate, double consTime, bool lowInc)

{

                if(lowInc){

                                //low income

                                if(consTime<=30){

                                                return 0;//no charges

                                }else{

                                                //charges are 40% of the regular hourly rate for the time over 30 minutes

                                                double extraMins=consTime-30;

                                                double billAmt=hRate*0.40*(extraMins/60);

                                                return billAmt;

                                }

                }else{

                                //high income

                                if(consTime<=20){

                                                return 0;//no charges

                                }else{

                                                //charges are 70% of the regular hourly rate for the time over 20 minutes

                                                double extraMins=consTime-20;

                                                double billAmt=hRate*0.70*(extraMins/60);

                                                return billAmt;

                                }

                }

}

/* OUTPUT 1*/

Enter yearly income: 24000

Enter the hourly rate: 70

Enter consulting time in minutes: 75

Bill amount: $21.00

/* OUTPUT2*/

Enter yearly income: 50000

Enter the hourly rate: 80

Enter consulting time in minutes: 90

Bill amount: $65.33

/* OUTPUT3*/

Enter yearly income: 33000

Enter the hourly rate: 75

Enter consulting time in minutes: 19

Bill amount: $0.00