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...
***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...
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...
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
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...
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
JAVA Program: You are a developer for a company that wants to create a new payroll...
JAVA Program: You are a developer for a company that wants to create a new payroll system. Write a program that can be used to calculate an employee’s take home pay. Example - rmckanryProgram1. Creating a flow chart or using stump code to outline your program first may help. Include the following features in the program: Enter employee’s name Enter employee’s base hourly pay Enter the number of hours worked for the week Error if the hours worked exceeds 168...
Q1:Write a Java program to find Fibonacci Series using 1) using for loop 2) using while...
Q1:Write a Java program to find Fibonacci Series using 1) using for loop 2) using while loop To Understand what the Fibonacci series is: The Fibonacci sequence is a series of numbers where a number is the sum of the previous two numbers. Starting with 0 and 1, the sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. Q2: Write a Java program to find the Factorial of a number using a while loop. To...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT