Pay stub Summary Building on the previous homework when empl
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!
 ************************************
*/


