Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

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 (

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 in C++ 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. Below is the code i have at the moment. I keep getting a "timed out" message on the testcase i am trying to pass it through. The subject is over User Defined Functions..

#include #include

using namespace std;

float gfHourRate = 0;

typedef struct { int iNoChargeMin; float fDiscount; } SDiscount;

class CTaxReturn { private: bool bLowIncome; int iConsultDurationMin; float price; SDiscount *psd; public: static const SDiscount sd[2]; CTaxReturn() { price = 0.0f; bLowIncome = false; iConsultDurationMin = 0; psd = (SDiscount *)&sd[0]; }

CTaxReturn(bool isLowincome, int iDuration) { set_numbers(isLowincome, iDuration); } const float& set_numbers(bool isLowincome, int iDuration) { bLowIncome = isLowincome; psd = (SDiscount *)&sd[bLowIncome ? 0 : 1]; iConsultDurationMin = iDuration; price = ((iConsultDurationMin - psd->iNoChargeMin)/60.0) * gfHourRate * psd->fDiscount; return price; }

};

const SDiscount CTaxReturn::sd[2] = {{30,0.4}, {20, 0.7}};

bool get_yesno(const string& strPrompt) { char yes = 0; do { cout "; yes = 0; cin >> yes; while(cin.get()!=' '); yes = tolower(yes); } while(yes != 'y' && yes != 'n'); return yes == 'y' ? true : false; }

template const T& get_number(const string& strPrompt, T& tNumber) { tNumber = 0; do { cout "; cin >> tNumber; while(cin.get() != ' '); if (cin.good()) break; } while (true); return tNumber; }

int main() { gfHourRate = get_number("What is the hourly rate?", gfHourRate); CTaxReturn tr; float fee = 0.0f; do{ int iMin = 0; iMin = get_number("Please enter consulting time (in minutes)", iMin); bool bLow = get_yesno("Do you earn less or equal $25,000.00?"); fee = tr.set_numbers(bLow, iMin); cout

Below are pictures of the failed testcases. There are 4 pictures

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

main.cpp User Defined 68 break 69 while (true); Functions 70 return tNurber During the tax season, every Friday, the 72 & accounting firm provides assistance 73 int natno to people who prepare their own tax 74 returns. Their charges are as follows: 75 gfHourRate get number "What us the hourly rate? gfHourRate); 76 CTaxReturn tr If a person has low income 77 float fee 0.0f 25,000) and the consulting time is less than or equal to 30 minutes 78 dof 79 int 1M1n 0; there are no charges; otherwise, 80 iMin get number ("Please enter consulting tire in Minutes) the service charges are 40% of the regular hourly rate for the time 81 bool bLow get yesno("Do you earn ess or equal $25,000.00?") over 30 minutes. 82 fee tr.set nunbers(bLow, 1 Min) For others, if the consulting time 83 cout "You have to pay fixed setprecision 2) fee is less than or equal to 20 endl minutes, there are no service 84 )while(get yesno("Do You want to continue?")); charges; otherwise, service 85 return 0 charges are 70% of the regular 86 hourly rate for the time over 20 87 minutes. Test Grade (For example, suppose that a person Run Code has low income and spent 1 hour and Type here to search Back Test Results 0/2 Passed 0.001% Score Calculation Your score may be calculated from test case output, unit est performance, code keywords and/or the presence of issues in your code. Test Case TIMED OUT: Other Income Test TIMED OUT: Low Income Test 48 AM main.cpp User Defined 68 break 69 while (true); Functions 70 return tNurber During the tax season, every Friday, the 72 & accounting firm provides assistance 73 int natno to people who prepare their own tax 74 returns. Their charges are as follows: 75 gfHourRate get number "What us the hourly rate? gfHourRate); 76 CTaxReturn tr If a person has low income 77 float fee 0.0f 25,000) and the consulting time is less than or equal to 30 minutes 78 dof 79 int 1M1n 0; there are no charges; otherwise, 80 iMin get number ("Please enter consulting tire in Minutes) the service charges are 40% of the regular hourly rate for the time 81 bool bLow get yesno("Do you earn ess or equal $25,000.00?") over 30 minutes. 82 fee tr.set nunbers(bLow, 1 Min) For others, if the consulting time 83 cout "You have to pay fixed setprecision 2) fee is less than or equal to 20 endl minutes, there are no service 84 )while(get yesno("Do You want to continue?")); charges; otherwise, service 85 return 0 charges are 70% of the regular 86 hourly rate for the time over 20 87 minutes. Test Grade (For example, suppose that a person Run Code has low income and spent 1 hour and Type here to search Back Test Results 0/2 Passed 0.001% Score Calculation Your score may be calculated from test case output, unit est performance, code keywords and/or the presence of issues in your code. Test Case TIMED OUT: Other Income Test TIMED OUT: Low Income Test 48 AM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago