Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Activity2PayStub class is part of Lab 3 and
- * creates a simple pay stub.
- *
- * @author Zachary Steele
- * @version 9-19-2017
- */
- public class Activity2PayStub
- {
- public static final double OVERTIME_FACTOR = 1.5;
- public static final double SS_TAX = .1;
- public static final double FED_TAX = .2;
- /**
- * It all starts with the main method.
- *
- * @param args command-line arguments (not used)
- */
- public static void main(String[] args)
- {
- Scanner kb = new Scanner(System.in);
- System.out.print("Enter your name: ");
- String name = kb.nextLine();
- System.out.print("Enter your Social Security Number (with hyphens): ");
- String social = kb.nextLine();
- System.out.print("Enter your regular hours worked (not overtime): ");
- int regh = kb.nextInt();
- System.out.print("Enter your overtime hours worked: ");
- int overh = kb.nextInt();
- System.out.print("Enter your hourly pay rate: ");
- double rate = kb.nextDouble();
- double regPay = regh * rate;
- double overRate = rate * OVERTIME_FACTOR;
- double overPay = overRate * overh;
- double grossPay = regPay + overPay;
- double ssTaxDeduction = grossPay * SS_TAX;
- double incomePostSS = grossPay - ssTaxDeduction;
- double fedTax = incomePostSS * FED_TAX;
- double netPay = incomePostSS - fedTax;
- String format = "Name: %-37s SSN: %-11s\n";
- String format1 = "Regular Hours: %-8d Reg Rate: "
- + "$%-8.2f Reg Pay: $%-8.2f\n";
- String format2 = "Overtime Hours: %-8dOT Rate: "
- + "$%-8.2f OT Pay: $%-8.2f\n";
- String format3 = "Gross Pay: $%-8.2f\n";
- String format4 = "SS Withholding: $%-8.2f\n";
- String format5 = "Federal Tax: $%-8.2f\n";
- String format6 = "Net Pay: $%-8.2f\n";
- System.out.print("______________________________________"
- + "___________________________\n");
- System.out.printf(format, name, social);
- System.out.printf(format1, regh, rate, regPay);
- System.out.printf(format2, overh, overRate, overPay);
- System.out.printf(format3, grossPay);
- System.out.printf(format4, ssTaxDeduction);
- System.out.printf(format5, fedTax);
- System.out.printf(format6, netPay);
- System.out.println("____________________________________"
- + "_____________________________");
- }
- /**
- * It all starts with the main method.
- */
- public void getInput(Scanner keyboard)
- {
- }
- /**
- * It all starts with the main method.
- */
- public void calculate()
- {
- }
- /**
- * It all starts with the main method.
- */
- public void printPayStub()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement