Question

In: Computer Science

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 over 40 hours, add double rate overtime pay for the hours worked more than 40 hours

Solutions

Expert Solution

import java.util.Scanner;


public class Payroll {

public static void main(String[] args) {

      
Scanner readData = new Scanner (System.in);
      
       While{

           System.out.print("press the "?" key to stop and exit: ");
           char key = readData.nextChar();
           if (key == "?") // This is how we break out of the loop. Processing "ESC" key involves more code
               break;
             
           //Let's gather employee data
           System.out.print("Enter employee's ID number: ");
           int empID = readData.nextInt();
           System.out.print("Enter employee's name: ");
           String name = readData.nextLine();
          
           System.out.print("Enter number of hours worked in the current week: ");
           int hours = readData.nextInt();
           System.out.print("Enter hourly wage: ");
           double wage = readData.nextDouble();
           System.out.print("Enter % federal tax rate without the % sign: ");
           int fedRate = readData.nextInt();
           System.out.print("Enter % state tax rate without the % sign: ");
           int stateRate = readData.nextInt();
             
           //let's compute deduction, overtime payment, gross pay and net pay
           if (hours <= 40)
               double grossPay = hours * wage;
           else
               double grossPay = (hours-40)* 2 * wage + 40 * wage;
           double fedTaxDeduction = ((fedRate/100.0) * grossPay);
           double stateTaxDeduction = ((stateRate/100.0) * grossPay);
           double netPay = grossPay - fedTaxDeduction - stateTaxDeduction;
             
           //let's format netPay to two decimal places
           netPay = (int)(netPay * 100)/100.0;
             
           //print payroll
           System.out.println("\n\nEmployee Id: " + empID);
           System.out.println("\n\nEmployee Name: " + name);
           System.out.println("Hours Worked: " + hours);
           System.out.println("hourly wage: $" + wage);
           System.out.println("Gross Pay: $" + grossPay);
           System.out.println(" Federal tax (" + (double)fedRate + "%): $" + FedTaxDeduction);
           System.out.println(" State tax (" + (double)stateRate + "%): $" + stateTaxDeduction);
           System.out.println("Net Pay: $" + netPay);
       } do  
}
}


Related Solutions

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...
For this assignment you will write a Java program using a loop that will play a...
For this assignment you will write a Java program using a loop that will play a simple Guess The Number game. Create a new project named GuessANumber and create a new Java class in that project named GuessANumber.java for this assignment. The program will randomly generate an integer between 1 and 200 (including both 1 and 200 as possible choices) and will enter a loop where it will prompt the user for a guess. If the user has guessed the...
***USING JAVA Scenario: You will be writing a program that will allow a user to find...
***USING JAVA Scenario: You will be writing a program that will allow a user to find and replace misspelled words anywhere in the phrase, for as many words as the user wishes. Once done (see example runs below), the program will print the final phrase and will show the Word Count, Character Count, the Longest Word and the Shortest Word. Requirements: Do not use Arrays for this assignment. Do not use any String class methods (.phrase(), replace methods, regex methods)...
Lesson on Inheritance in Java: Using the payroll weekly paycheck calculator scenario as a model, your...
Lesson on Inheritance in Java: Using the payroll weekly paycheck calculator scenario as a model, your code will consist of a superclass (Employee), three subclasses (SalaryEmployee, HourlyEmployee, CommEmployee) and a test class (PayrollTest). - The superclass should contain fields for common user data for an employee (first name and last name) and a toString method that returns the formatted output of the names to the calling method. - Three subclasses should be created that all inherit from the superclass: one...
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to...
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to input two numbers using scanner class Print the instruction of the menu for the calculator program Ask user to press 0 to Quit Ask user to press 1 to Add Ask user to press 2 to Substract Ask user to press 3 to Multiply Ask user to press 4 to Divide Perform correct calcuation based on user inputs and print the result Print error...
Programing Language: Java The Problem: You are writing a program that encrypts or decrypts messages using...
Programing Language: Java The Problem: You are writing a program that encrypts or decrypts messages using a simple substitution cipher. Your program will use two constant strings. One will represent the code for encryption: going from the original message (called the plaintext) to the encrypted version of the message. The other will be “abcdefghijklmnopqrstuvwxyz” (the lowercase alphabet. Your program will ask the user whether they want to 1) encrypt a message, 2) decrypt a message, or 3) quit. If they...
Write a program that produces the following output using nested for loop in Java. ****** ////////////...
Write a program that produces the following output using nested for loop in Java. ****** //////////// ****** ***** //////////\\ ***** **** ////////\\\\ **** *** //////\\\\\\ *** ** ////\\\\\\\\ ** * //\\\\\\\\\\ * \\\\\\\\\\\\
This is for a java program. Payroll System Using Inheritance and Polymorphism 1. Implement an interface...
This is for a java program. Payroll System Using Inheritance and Polymorphism 1. Implement an interface called EmployeeInfo with the following constant variables: FACULTY_MONTHLY_SALARY = 6000.00 STAFF_MONTHLY_HOURS_WORKED = 160 2. Implement an abstract class Employee with the following requirements: Attributes last name (String) first name (String) ID number (String) Sex - M or F Birth date - Use the Calendar Java class to create a date object Default argument constructor and argument constructors. Public methods toString - returning a string...
Using a while loop. Write a JAVA program that asks a user for an integer between...
Using a while loop. Write a JAVA program that asks a user for an integer between 1 and 9. Using the user input, print out the Fibonaccci series that contains that number of terms. Sample output: How many terms would like printed out for the Fibonacci Sequence? 7 Fibonacci Series of 7 numbers: 0 1 1 2 3 5 8
Write a Java program using using WHILE loop to find the sum of all integers between...
Write a Java program using using WHILE loop to find the sum of all integers between 200 to 250 which are divisible by 7. Sample Output: Numbers between 200 and 250, divisible by 7: 203 210 217 224 231 238 245 The sum is: 1568
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT