Question

In: Computer Science

The program you will be writing displays a weekly payroll report. A loop in the program...

The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee's number, last name, worked hours, hourly pay rate, state tax and federal tax rate. After data in entered and the user hits the enter key, the program will calculate gross an net pay, then displays all employee's payroll information, and ask for the next employees' information. if worked hour is more than 40, double pay the hours worked more than 40 hours.

In the program, after done first employee, display "would you like to enter next employee's information?"

if the user type "y", "Y", "YES", "Yes", "YEs", "yES", "yeS", the program should prompt for second employee info entry.

if the user type "n", "N", "No","NO", nO", "no", the program should exit.

Need the code in Java (I have struggle in the big loop when asking input second employee's info or not).

Solutions

Expert Solution

If you have any doubts, please give me comment...

import java.util.Scanner;

public class WeeklyPayroll{

    public static void main(String[] args) {

        Scanner scnr = new Scanner(System.in);

        String empNumber, lname, response;

        double worked_hours, hourly_pay_rate, state_tax_rate, federal_tax_rate, taxes;

        double gross_pay, net_pay;

        do{

            System.out.print("Enter employee number: ");

            empNumber = scnr.next();

            System.out.print("Enter employee lastname: ");

            lname = scnr.next();

            System.out.print("Enter employee worked hours: ");

            worked_hours = scnr.nextDouble();

            System.out.print("Enter employee hourly pay rate: ");

            hourly_pay_rate = scnr.nextDouble();

            System.out.print("Enter state tax: ");

            state_tax_rate = scnr.nextDouble();

            System.out.print("Enter federal tax: ");

            federal_tax_rate = scnr.nextDouble();

            gross_pay = worked_hours*hourly_pay_rate;

            if(worked_hours>40)

                gross_pay += (worked_hours-40)*hourly_pay_rate;

            taxes = gross_pay*(state_tax_rate/100) + gross_pay*(federal_tax_rate/100);

            net_pay = gross_pay + taxes;

            System.out.println("\nEmployee Number: "+empNumber);

            System.out.println("Last Name: "+lname);

            System.out.println("Worked hours: "+worked_hours);

            System.out.println("Hourly Pay rate: "+hourly_pay_rate);

            System.out.println("Gross Pay: $"+gross_pay);

            System.out.println("Tax: $"+taxes);

            System.out.println("Net Pay: $"+net_pay);

            System.out.print("\nwould you like to enter next employee's information? ");

            response = scnr.next();

        }while(response.equalsIgnoreCase("yes") || response.equalsIgnoreCase("y"));

    }

}


Related Solutions

Using Java, The program you will be writing displays a weekly payroll report. A loop in...
Using Java, The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee’s number, employee’s last name, number of hours worked, hourly pay rate, state tax, and federal tax rate. After the data is entered and the user hits the enter key, the program will calculate gross and net pay then displays employee’s payroll information as follows and asks for the next employees’ information. if the user works...
Write a program that displays a weekly payroll report. A loop in the program should ask...
Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: Do not accept negative numbers for any of the items entered. Do not...
write a report about travel agency in c++ not a program writing just report writing
write a report about travel agency in c++ not a program writing just report writing
/* Writing a program that displays the following: calculating area of a circle, calculating area of...
/* Writing a program that displays the following: calculating area of a circle, calculating area of a rectangle, calculating area of a triangle, and quit. */ import java.text.DecimalFormat; import java.util.Scanner; public class GeoCalculator {    public static void main(String arg[]) { char selection; Scanner get = new Scanner(System.in); //having user input DecimalFormat twoDigits = new DecimalFormat("0.00"); //formatting area to two decimal places //display choice of selection System.out.println("Geometry Calculator"); System.out.println("Please select from the following menu:"); System.out.println("1. Calculate the Area of a...
General Description: Write a program that processes weekly payroll for a small company. The program starts...
General Description: Write a program that processes weekly payroll for a small company. The program starts with printing a logo then asking for the total number of employees for the week. The program then inputs data for each individual employee and prints a paystub. At the end, it prints a report based on data for all employees. Gross Pay: The company has two types of employees: Hourly and Salaried - Hourly employees have an hourly wage, and are paid overtime...
Bonus Homework for Week 5 Preparing a Weekly Payroll Report Employee Name Gross Weekly Pay State...
Bonus Homework for Week 5 Preparing a Weekly Payroll Report Employee Name Gross Weekly Pay State Withholding Tax Federal Withholding Tax Net Pay Sue Smith $800 ________________ ________________ Tom Brown $300 ________________ ________________ Mary Wilson $250 ________________ ________________ James Jackson $100 ________________ ________________ John Sinatra $600 ________________ ________________ Betty Rockford $1,255 ________________ ________________ Similar assignment as our in-class IF function work - you must calculate the amount of State Withholding Tax and Federal Withholding Tax. Also calculate Net Pay. Watch-out...
You are preparing the weekly payroll for the week ending March 10th. There are four employees...
You are preparing the weekly payroll for the week ending March 10th. There are four employees and their timecards along with a summary of deductions/benefits are listed below. Overtime is calculated based on Ontario Labour standards. Shift premium is $.97 per hour for afternoons and $1.57 per hour for midnights. Using the timecards below, calculate the number of hours paid at the regular time, overtime and shift premium hours. Once you have that information calculate their gross earnings for the...
You are preparing the weekly payroll for the week ending March 10th. There are four employees...
You are preparing the weekly payroll for the week ending March 10th. There are four employees and their timecards along with a summary of deductions/benefits are listed below. Overtime is calculated based on Ontario Labour standards. Shift premium is $.97 per hour for afternoons and $1.57 per hour for midnights. Using the timecards below, calculate the number of hours paid at the regular time, overtime and shift premium hours. Once you have that information calculate their gross earnings for the...
Boxcom Company had a total bi-weekly payroll of $ 90,000. The entire payroll was subject to...
Boxcom Company had a total bi-weekly payroll of $ 90,000. The entire payroll was subject to CPP (4.95%), EI (1.66%), and income tax withholdings of $ 11,880. Union dues of $ 1,125 and Health insurance premiums of $ 2,850 were also withheld. Boxcom will match employee CPP and 1.4 times employees EI Instructions                                             Prepare the journal entries to record the employee wages/salaries and payroll deductions Prepare the journal entries to record the employer payroll contributions    Prepare the journal entries to...
In this exercise, you will create a program that displays the amount of a cable bill....
In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer, as shown in Figure 10-30. For a residential cus- tomer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. If necessary, create a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT