Question

During the tax season, every Friday, 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) an...

During the tax season, every Friday, J&J accounting firm provides assistance to people who prepare their own tax returns. Their charges are as follows:

  1. 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 srvice charges 40% of the regular hourly rate for the time over 30 minutes.
  2. 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, spent 1 hour and 15 minutes, and the hourly rate is $70.00. Then the billing amount is 70.00*0.40*((75-30)/60) = $21.00.)

Write a program that prompt the user to enter the hourly rate, the total consulting time, and if the person has low income. The program should output the billing amount. Your program must be implemented using methods. Failure to do so will result in azero for the program even if you have a correct running program.

The methods your program must include:

  • A method that returns the yearly income
  • A method that returns the hourly rate
  • A method that returns the consulting time in minutes
  • A method that compute the billing amount that takes the hourly rate, the total consulting time, and a value indicating if the person has low income as parameters.
  • A method that prints the output.
  • A void greeting method
  • A void goodbye method.

Input/Output Format:

Welcome to J&J Accounting Firm!

Glad to help you calculate your cost for filing 2018 taxes with us.

Do you want to CONTINUE or STOP?

continue

Enter yearly income: 24500

Enter hourly rate: 70

Enter consulting time in minutes: 75

The billing amount is: $21.00

Based on: $24500.00 of yearly income, 75.00 minutes of help and reduce rate of $70.00 per hour.

Do you want to CONTINUE or STOP?

Continue

Enter yearly income: 26000

Enter hourly rate: 80

Enter consulting time in minutes: 90

The billing amount is: $65.33

Based on: $26000.00 of yearly income, 90.00 minutes of help and reduce rate of $80.00 per hour.

Do you want to CONTINUE or STOP?

ConTINUE

Enter yearly income: 10000

Enter hourly rate: 60

Enter consulting time in minutes: 15

The billing amount is: $0.00

Based on: $10000.00 of yearly income, 15.00 minutes of help and reduce rate of $60.00 per hour.

Do you want to CONTINUE or STOP?

Stop

Thanks for visiting J&J Accounting.

Please allow us to file your 2018 Taxes. Thank you!

I'm having trouble with methods in this java program. I can't seem to get the program to run with the correct output

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// Accounting.java

import java.util.Scanner;

public class Accounting {
   /*
   * Creating an Scanner class object which is used to get the inputs
   * entered by the user
   */
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args) {
  
      
       greet();
       while(true)
       {
           //Getting the character from the user 'Y' or 'y' or 'N' or 'n'
           System.out.print("Do you want to CONTINUE or STOP?");
           String str = sc.next();
           if(str.equalsIgnoreCase("CONTINUE"))
           {
               double yearlyIncome=getYearlyIncome();
               double hourlyRate=getHourlyRate();
               int consultTime=getConsultingTime();
               double billingAmt=computeBillingAmount(hourlyRate,consultTime,yearlyIncome);
               System.out.printf("The billing amount is: $%.2f\n",billingAmt);
           }
           else
           {
           System.out.println(":: Program Exit ::");
           break;
           }
  
       }
      
       goodBye();
      

   }

   private static double computeBillingAmount(double hourlyRate,
           int consultTime, double yearlyIncome) {
       double billingAmt=0;
       if(yearlyIncome<=25000)
       {
   if(consultTime<=30)
   {
   billingAmt=0;
   }
   else if(consultTime>30)
   {
   billingAmt=hourlyRate*0.40*(consultTime-30)/(double)60;
   }
       }
   else if(consultTime<=20)
   {
   billingAmt=0;
   }
   else
   {
   billingAmt=hourlyRate*0.70*(consultTime-20)/(double)60;
     
   }
   return billingAmt;
   }

   private static int getConsultingTime() {
       System.out.print("Enter consulting time in minutes: ");
       int time=sc.nextInt();      
       return time;

   }

   private static double getHourlyRate() {
       System.out.print("Enter hourly rate: ");
       double rate=sc.nextDouble();      
       return rate;
   }

   private static double getYearlyIncome() {
       System.out.print("Enter yearly income: ");
       double income=sc.nextDouble();
       return income;
   }

   private static void goodBye() {
       System.out.println("Thanks for visiting J&J Accounting.");
       System.out.println("Please allow us to file your 2018 Taxes. Thank you!");
   }

   private static void greet() {
       System.out.println("Welcome to J&J Accounting Firm!");
       System.out.println("Glad to help you calculate your cost for filing 2018 taxes with us.");      
   }

}

_____________________

Output:

Welcome to J&J Accounting Firm!
Glad to help you calculate your cost for filing 2018 taxes with us.
Do you want to CONTINUE or STOP?continue
Enter yearly income: 26000
Enter hourly rate: 80
Enter consulting time in minutes: 90
The billing amount is: $65.33
Do you want to CONTINUE or STOP?continue
Enter yearly income: 10000
Enter hourly rate: 60
Enter consulting time in minutes: 15
The billing amount is: $0.00
Do you want to CONTINUE or STOP?continue
Enter yearly income: 24500
Enter hourly rate: 70
Enter consulting time in minutes: 75
The billing amount is: $21.00
Do you want to CONTINUE or STOP?stop
:: Program Exit ::
Thanks for visiting J&J Accounting.
Please allow us to file your 2018 Taxes. Thank you!


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
During the tax season, every Friday, 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) an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ exercises During the tax season, every Friday, the J&J accounting firm provides assistance to people...

    C++ exercises 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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT