#include <iostream> #include<iomanip> #include <string> using namespace std; dou
ID: 3675024 • Letter: #
Question
#include <iostream>
#include<iomanip>
#include <string>
using namespace std;
double billingAmount(double hourlyRate, double consultingTime, string lowIncome);
int main()
{
double hourlyRate;
double consultingTime;
string lowIncome;
cout << "Enter the hourly rate: $";
cin >> hourlyRate;
cout << "Enter the consulting time in minutes: ";
cin >> consultingTime;
cout << "Is Client Low Income (Enter Y or N): ";
cin >> lowIncome;
cout << fixed << showpoint << setprecision(2);
cout << "Total Cost of Consultaion will be: $" << billingAmount(double hourlyRate, double consultingTime, string lowIncome);
return 0;
}
double billingAmount(double hourlyRate, double consultingTime, string lowIncome){
if (lowIncome <= 25000 ) {
if (consultingTime <= 30)
return 0;
else
return hourlyRate * 0.40 * ((consultingTime - 30) / 60);
}
else {
if (consultingTime <= 20)
return 0;
else
return hourlyRate * 0.70 * ((consultingTime - 20) / 60);
}
}
I need help with my code, the prompt is
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 x 0.40 x (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 whther 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.
Function Definition : double billingAmount(double hourlyRate, double consultingTime, string lowIncome) ;
The output should look just like this :
Enter Hourly Rate : 70.00
Enter Consulting Time in Minutes : 110
Is Client Low Income (Enter Y or N) : Y
Total Cost of Consultation will be : $37.33
Explanation / Answer
#include <iostream>
#include<iomanip>
#include <string>
using namespace std;
double billingAmount(double hourlyRate, double consultingTime, double lowIncome);
int main()
{
double hourlyRate;
double consultingTime;
double lowIncome;
char isLowIncome ;
cout << "Enter the hourly rate: $";
cin >> hourlyRate;
cout << "Enter the consulting time in minutes: ";
cin >> consultingTime;
cout << "Is Client Low Income (Enter Y or N): ";
cin >> isLowIncome;
if(isLowIncome == 'Y'){
cout << "Enter the low income ammount: ";
cin>>lowIncome;
}
cout << fixed << showpoint << setprecision(2);
cout << "Total Cost of Consultaion will be: $" << billingAmount( hourlyRate, consultingTime, lowIncome);
return 0;
}
double billingAmount(double hourlyRate, double consultingTime, double lowIncome){
if (lowIncome <= 25000 ) {
if (consultingTime <= 30)
return hourlyRate * ((consultingTime - 30) / 60);// no any tax
else
return hourlyRate * 0.40 * ((consultingTime - 30) / 60);
}
else {
if (consultingTime <= 20)
return hourlyRate * ((consultingTime - 20) / 60);
else
return hourlyRate * 0.70 * ((consultingTime - 20) / 60);
}
}
/*
Output:
Enter the hourly rate: $70
Enter the consulting time in minutes: 110
Is Client Low Income (Enter Y or N): Y
Enter the low income ammount: 2500
Total Cost of Consultaion will be: $37.33
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.