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

A firm provides assistance to people who prepare their own tax return. The servi

ID: 675500 • Letter: A

Question

A firm provides assistance to people who prepare their own tax return. The service 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 hours 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.

Write a Java program that uses a User-Defined method to calculate the service charges for customers.

a) It asks the user to input the hourly rate, the total consulting time in minutes, and the income.

b) It then call the user-defined method with appropriate actual parameters to get the service charge

c) The user-defined method takes the hourly rate, the total consulting time in minutes, and the income as the formal parameters, and then calculates and returns the service charges.

d) User inputs should be validated

e) In addition to the requirements described above, use a loop in the main() method to repeatedly accept user input for several customers and call the user defined method to get the result until the user chooses not to.

f) Do not use global variables for this program!!!

Explanation / Answer

import java.io.*;
import java.util.Scanner;
class TaxAssistanceCharges
{
public static double serviceTaxCalc(double hourlyRate, int consultingTime, double income)
{
if(income <= 25000)
{
consultingTime = (consultingTime > 30 ? consultingTime-30 : 0);
return hourlyRate/60 * .4 * consultingTime;
}
else
{
consultingTime = (consultingTime > 20 ? consultingTime-20 : 0);
return hourlyRate/60 * .7 * consultingTime;
}
}

public static void main(String[] args)
{
double hourlyRate, income;
int consultingTime;
boolean haveMoreCustomers = true;
Scanner sc = new Scanner(System.in);
while(haveMoreCustomers)
{
System.out.print("Enter the hourly rate of the consultant: ");
hourlyRate = sc.nextDouble();
System.out.print("Enter the consulting time of the customer(in minutes): ");
consultingTime = sc.nextInt();
System.out.print("Enter the income of the customer: ");
income = sc.nextDouble();
System.out.println("The service to be paid by the customer is: "+serviceTaxCalc(hourlyRate, consultingTime, income));
System.out.print("Do you have more customers (true/false): ");
haveMoreCustomers = sc.nextBoolean();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote