Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- *Activity1PayStub class is part of Lab 3 and
- *creates a simple pay stub.
- *
- * @author Ethan Carr
- * @version 9/9/2014
- */
- public class Activity1PayStub
- {
- public static final
- double OVERTIME_FACTOR = 1.5;
- double OVERTIME_RATE = 1.5;
- double SS_RATE = .1;
- double TAX_RATE = .2;
- /**
- *It all starts with the main method.
- *
- * @param args command-line arguments (not used)
- */
- public static void main(String[] args)
- {
- String name;
- String ssn;
- int hours;
- int overtime;
- double payRate;
- double regularPay;
- double overtimeRate;
- double overtimePay;
- double grossPay;
- double socialSecurityWitholding;
- double federalTax;
- double netPay;
- Scanner keyboard = new Scanner(System.in);
- System.out.print("What is your name? ");
- name = keyboard.nextLine();
- System.out.print("What is your social security number? ");
- ssn = keyboard.nextLine();
- System.out.print("How many regular (not overtime) hours did you work this week? ");
- hours = keyboard.nextInt();
- System.out.print("How many overtime hours did you work this week? ");
- overtime = keyboard.nextInt();
- System.out.print("What is your hourly pay rate? ");
- payRate = keyboard.nextDouble();
- regularPay = hours * payRate;
- overtimeRate = payRate * 1.5;
- overtimePay = overtimeRate * overtime;
- grossPay = regularPay + overtimePay;
- socialSecurityWitholding = grossPay * .1;
- federalTax = (grossPay - socialSecurityWitholding) * .2;
- netPay = grossPay - socialSecurityWitholding - federalTax;
- System.out.println("____________________________________________________________");
- String format = "Name: %-37s SSN: %-11s\n";
- System.out.printf(format, name, ssn);
- format = "Regular Hours: %-8d Reg Rate: $%-8.2f Reg Pay: $%-8.2f\n";
- System.out.printf(format, hours, payRate, regularPay);
- format = "Overtime Hours: %-8dOT Rate: $%-8.2f OT Pay: $%-8.2f\n";
- System.out.printf(format, overtime, overtimeRate, overtimePay);
- format = "Gross Pay: $%-8.2f\n";
- System.out.printf(format, grossPay);
- format = "SS Withholding: $%-8.2f\n";
- System.out.printf(format, socialSecurityWitholding);
- format = "Federal Tax: $%-8.2f\n";
- System.out.printf(format, federalTax);
- format = "Net Pay: $%-8.2f\n";
- System.out.printf(format, netPay);
- System.out.println("____________________________________________________________");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement