Question

Introduction to computer class, Java programming through eclipse:

Ue the following criteria to create the code: SALARY

Input first and last name

- Output the names last, first in your output

- Make the federal withholding rate a constant 20% (not an input value)

No state tax

Generate two new values: regular pay and overtime pay

- 40 hours workedor less

- Regular pay is pay rate * hours worked

- Overtime pay is 0

Otherwise

- Regular pay is pay rate * 40

- Overtime is pay rate * (hours –40)* 1.5

- Gross pay is then regular pay + overtime pay

Output should be similar to the instructions in the bookexcept:

- Regular and overtime pay includedostate tax not included

- all currency should be rounded to 2 decimals

SAMPLE CODE:

Sample run: Enter first and last name: Fred Flintstone Enter hours worked: 40.25 Enter hourly pay rate: $36.00 Employee name: Flintstone, Fred Hours worked: 40.25 Hourly Rate: $36.00 Gross Pay: $1453.50 Regular Pay: $1440.00 Overtime Pay: $13.50 Deductions: Federal Tax: $290.70 Total deductions: $290.70 Net Pay: $1162.80

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

import java.util.Scanner;
public class Salary{

public static void main(String []args){
Scanner sc = new Scanner(System.in).useDelimiter("\\s");
System.out.print("Enter first and last name: ");
String firstName = sc.next();
String lastName = sc.next();
//Scanner sc1 = new Scanner(System.in);
sc.nextLine();
System.out.print("\nEnter hours worked: ");
double hoursWorked = sc.nextDouble();
System.out.print("\nEnter hourly pay rate: $");
sc.nextLine();
double hourlyPayRate = sc.nextDouble();
System.out.print("\nEmployee Name: "+lastName+", "+firstName);
System.out.print("\nHours Worked: "+hoursWorked);
System.out.print("\nHourly Rate: $"+hourlyPayRate);
double grossPay,regularPay,overTimePay;
if(hoursWorked<=40)
{
grossPay = hoursWorked*hourlyPayRate;
regularPay = grossPay;
overTimePay = 0.00;
}
else
{
regularPay = 40*hourlyPayRate;
overTimePay = (hoursWorked - 40)*hourlyPayRate*1.5;
grossPay = regularPay+overTimePay;
  
}
  
System.out.print("\nGross Pay: $"+grossPay);
System.out.print("\n Regulat Pay: $"+regularPay);
System.out.print("\n Overtime Pay: $"+overTimePay);
  
double deductions = grossPay*0.2;
  
System.out.print("\nDeductions:");
System.out.print("\n Federal Tax: $"+deductions);
System.out.print("\n Total Deductions: $"+deductions);
System.out.print("\nNet Pay: $"+(grossPay-deductions));
}
}

Add a comment
Know the answer?
Add Answer to:
Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code:...
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
  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • Create a dual-alternative selection structure using Python: A company ABC asked you to design a simple...

    Create a dual-alternative selection structure using Python: A company ABC asked you to design a simple payroll program that calculates and employee's weekly gross pay, including any overtime wages. If employees work over 40 hours in a week, they will get 1.5 times of their regular hourly rate for all hours over 40. Your program asks the user to input hours worked for a week, regular hourly rate, and then display the weekly gross pay Output sample Enter weekly hours...

  • Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string...

    Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string first, last, job;    double hours, wages, net, gross, tax, taxrate = .40;    double oPay, oHours;    int deductions;    // input section    cout << "Enter First Name: ";    cin >> first;    cout << "Enter Last Name: ";    cin >> last;    cin.ignore();    cout << "Enter Job Title: ";    getline(cin, job);    cout << "Enter Hours Worked:...

  • Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class...

    Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class (which inherits from the Employee class) for a basic payroll program to compute the net pay salary of hourly based employees. Your program should also find the average net pay for a small company. To define the class, include the appropriate data members, member functions, constructors, and access modifiers. For simplicity, use a constant tax rate of 30% to compute the tax amount. Employees...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • Write a c++ program to create a payroll based on these assumptions and requirements: A company...

    Write a c++ program to create a payroll based on these assumptions and requirements: A company called Data Housing Corp. employs a number of employees (say 5) all employees are paid on hourly base, any employee who works more than 40 hours is entitled to be paid overtime (1.5 for every hour exceeding 40). Calculate : 1. The Gross income=(Rate*hours worked )+ overtime 2. The overtime= No. of hours exceeding 40 * Rate *1.5 3. State tax= gross*6% 4.Federal tax=gross*12%...

  • Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K....

    Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K. Mello Company has three employees-a consultant, employee Administrator Consultant Computer Programmer $3,110 per week Regular earnings rate $36 per hour $44 per hour Overtime earnings rate 1.5 times hourly rate Not applicable 2 times hourly rate Federal income tax withheld $930 $244 $510 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay period,...

  • K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll...

    K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,610 per week $32 per hour $46 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $915 $255 $505 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay period, the...

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