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

Create a payroll program named CalcPay that allows the user to enter Name, Hours

ID: 3695867 • Letter: C

Question

Create a payroll program named CalcPay that allows the user to enter Name, Hours, and rate. After the user enters the rate, hours, and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Create an output file named '"Payout" The file should include: Name, hours, rate, deduct, gross and net. You are to process ten employees or stop the program by entering -999. Display the total amount of tax collected and the total gross and net for all employees.

Explanation / Answer

import java.util.*;
import java.io.*;

class CalcPay
{
   public static void main(String args[]) throws IOException
   {
       String name;
       int hr;
       double ra,tax,gpay,net;
       int i=0;
  
       Scanner scan = new Scanner(System.in);

       while(i<10)
       {
           System.out.println("Enter Name");
           name=scan.next();

           if(name.equals("-999"))
               break;

           System.out.println("Enter Hours");
           hr=scan.nextInt();
              
           System.out.println("Enter Rate");
           ra=scan.nextDouble();

           gpay=hr*ra;

           if(gpay>=600)
               tax=gpay*21/100;
           else if(gpay>=300)
               tax=gpay*18/100;
           else if (gpay>=100)
               tax=gpay*12/100;
           else
               tax=gpay*6/100;

           net = gpay-tax;
           File outFile = new File ("Payout.txt");
           FileWriter fWriter = new FileWriter (outFile);
           PrintWriter pWriter = new PrintWriter (fWriter);
           pWriter.println (name+","+hr+","+ra+","+tax+","+gpay+","+net);
  
       }
   }
}

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