Pay stub Summary Building on the previous homework when empl

Pay stub Summary Building on the previous homework, when employees submit a timesheet (recording the hours they worked) at the subsequent pay period, they will be given a paystub that details the amount of their pay minus deductions (e.g. taxes, insurance, etc.). Deductions can be complex to calculate as there are many factors that must be considered (e.g. in 2017, \"only\" the first $127,200 of income for the year is taxed for social security purposes). For this homework, we will simplify deductions into two categories: \"fixed\" as well as \"percentage based. Estimated Work Needed This assignment took me about 10-15 minutes to write (not including challenges, but including testing, commenting, and cleanup) in about 100 lines of code. In other words, you should expect to spend between 45 to 150 minutes working on this assignment. If you\'ve spent more than 2.5 hours working on this assignment, then you likely did not understand how data flow into and out of methods and should re-read the lecture slides (and attempt the exercises within), seek help from your fellow classmates, myself, your lab instructor, QSC tutor, as well as online resources. Skills Expected All the skills from previous Assignment (s) Conditional Expressions and Statements Assignment Description Write a program that does the following: Ask the user for the following: First Name o Last Name o Number of Hours Worked (since the last pay period) Create the following methods: o A method that takes in as arguments the first and last name and prints out a \"header\" A method that takes in as arguments the number of hours worked and O Calculates the \"Gross Income\" (Income before taxes) based on the following: Hourly Rate: $15/hr. Hours given are hours worked since the last pay period. A pay period lasts two weeks at 40 hours per week. Any hours worked beyond 80 hours since the last pay period is to be paid 1.5x e regular hourly rate and be counted as \"Overtime Income.

Solution

// Paystub.java
import java.util.Scanner;
public class Paystub
{

   public static void header(String firstName, String lastName)
   {
       System.out.println(\"************************************\");
       System.out.println(\"Paystub for \" + lastName + \", \" + firstName);
       System.out.println(\"************************************\");
   }
  
   public static void display(double grossIncome, int hours)
   {
       double insurance = (hours/80)*50;
       double taxes = (grossIncome- insurance )*0.3;
       double takeHome = grossIncome-taxes-insurance;

       System.out.println(\"Medical and Dental Insurance: $\" + insurance);
       System.out.println(\"Federal Taxes: $\" + taxes);
       System.out.println(\"Takehome Income: $\" + takeHome);
   }

   public static double getGrossIncome(int hours)
   {
       int rate = 15;
       int overtime = (hours-80);
       double overtimeIncome, grossIncome, regularIncome;

       if (overtime > 0)
       {
           regularIncome = 80*rate;
           overtimeIncome = overtime*1.5*rate;   
       }
       else
       {
           overtimeIncome = 0.0;
           regularIncome = hours*rate;
       }

       grossIncome = overtimeIncome + regularIncome;

       System.out.println(\"Regular Income: $\" +regularIncome );
       System.out.println(\"Overtime Income: $\" +overtimeIncome );
       System.out.println(\"Gross Income: $\" +grossIncome );

       return grossIncome;
   }
   public static void main(String[] args)
   {
       Scanner keyboard = new Scanner (System.in);
       System.out.print(\"What is your first name? \");
       String firstName = keyboard.next();
       System.out.print(\"What is your last name? \");
       String lastName = keyboard.next();
       System.out.print(\"How many hours have you worked since the last pay period? \");
       int hours = keyboard.nextInt();

       header(firstName,lastName);
       double grossIncome = getGrossIncome(hours);
       display(grossIncome,hours);

       System.out.println(\"************************************\");
       System.out.println(\"Thanks for using out system!\");
       System.out.println(\"************************************\");
   }
  
}


/*
output:

What is your first name? Hansel
What is your last name? Ong
How many hours have you worked since the last pay period? 120
************************************
Paystub for Ong, Hansel
************************************
Regular Income: $1200.0
Overtime Income: $900.0
Gross Income: $2100.0
Medical and Dental Insurance: $50.0
Federal Taxes: $615.0
Takehome Income: $1435.0
************************************
Thanks for using out system!
************************************

*/

 Pay stub Summary Building on the previous homework, when employees submit a timesheet (recording the hours they worked) at the subsequent pay period, they will
 Pay stub Summary Building on the previous homework, when employees submit a timesheet (recording the hours they worked) at the subsequent pay period, they will

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site