So, I have to do a homework problem that entails the following:
During the tax season, every Friday, J&J accounting firm privides assistance to people who prepare their own tax returns. Their charges are as follows.
a. 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.
b. 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. The 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. The program may prompt the user to enter the consulting time in minutes.
Here is my code:
#include <iostream>
#include <iomanip>
using namespace std;
const int HOUR = 60;
int minutes = 0;
double intake(payment);
void intake()
{
char income, y('y'), n('n');
cout << "Is the income rate over 25,000? Y - Yes | N - No): ";
cin >> income;
switch(income)
{
case 'n':
case 'N': low_procedure()
break;
case 'y':
case 'y': high_procedure()
break;
default: cout << "Invalid entry. You must indicate low or high income.\n"
break;
}
}
int main()
{
intake();
cout<<"You owe: \n";
cout<< payment <<endl;
}
double low_procedure()
{
const double LOW_DISCOUNT = 0.40;
const int LOW_TIME = 30;
consult = getConsultTime()
rate = getRate()
if consult > LOW_TIME
{
minutes = consult - LOW_TIME
result = rate * LOW_DISCOUNT
payment = calcPay
}
else
cout <<"No additional fees. \n";
return payment;
}
double high_procedure()
{
const double HIGH_DISCOUNT = 0.70;
const int HIGH_TIME = 20;
consult = getConsultTime()
rate = getRate()
if consult > HIGH_TIME
{
minutes = consult - HIGH_TIME
result = rate * HIGH_DISCOUNT
}
else
cout<<"No additional fees.";
}
int getConsultTime()
{
int consult = 0;
cout << "How long was the consult for in minutes? \n";
cin >> consult;
return consult;
}
double getRate()
{
double rate = 0.00;
cout << "What was the hourly rate? \n";
cin >> rate;
return rate;
}
double calcPay
{
double payment = 0.00;
payment = result * (minutes/HOUR);
return payment;
}
I've been having a lot of trouble here since I realized that I need to declare variables in code. I have a feeling I'm making this more complex than it needs to be, but the switch statement is important. I'm trying to sieve through bad, unimportant data.