Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.NumberFormat;
- import java.util.Scanner;
- class Payroll
- {
- public static void main(String [] args){
- //variables; hours, dependant(s), overtime
- int hours;
- Scanner console = new Scanner(System.in);
- System.out.println("Please enter the amount of hours worked ");
- hours = console.nextInt();
- int dependant;
- System.out.println("Please enter the amount of dependant ");
- dependant = console.nextInt();
- Scanner scan = new Scanner(System.in);
- int overtime;
- System.out.println("Please enter the amount of overtime you done for the week ");
- overtime = console.nextInt();
- //taxes and income
- double grosspay;
- double weekpay;
- double FederalTax;
- double SocialSecurityTax;
- double StateIncomeTax;
- //payrate, taxes, union charge; My constants
- double rate = 18.28;
- double socialsecuritytax = .06;
- double federalincometax = .13;
- double stateincometax = .05;
- double unionduecharge = 11;
- //Calculations
- if(hours > 40)
- {
- grosspay = (rate * 40) + (1.5 * rate * overtime);
- }
- else
- {
- grosspay = rate * hours;
- }
- if(dependant > 2)
- {
- grosspay = (rate * 40) + (1.5 * rate * overtime) - 35;
- }
- else
- {
- grosspay = (rate * 40) + (1.5 * rate * overtime) - 11;
- }
- weekpay = grosspay - (grosspay * federalincometax) - (
- grosspay * socialsecuritytax) -
- (grosspay * stateincometax) - unionduecharge;
- FederalTax = grosspay * federalincometax;
- SocialSecurityTax = grosspay * socialsecuritytax;
- StateIncomeTax = grosspay * stateincometax;
- NumberFormat format = NumberFormat.getCurrencyInstance();
- do {
- System.out.println("You enter a negative number for hours.");
- }while (hours<0);
- do{
- System.out.println("You enter a negative dependant.");
- }while(dependant<0);
- do{
- System.out.println("You enter negative overtime.");
- }while(overtime<0);
- if(hours <=100 && dependant<=2 && overtime <=60){
- System.out.println("This is your gross pay "
- +format.format(grosspay));
- System.out.println("Federal Tax with holding "
- +format.format(FederalTax));
- System.out.println("Social Security Tax with holding "
- +format.format(SocialSecurityTax));
- System.out.println("State Income Tax with holding "
- +format.format(StateIncomeTax));
- System.out.println("This is your week pays after deductions "
- +format.format(weekpay));
- }
- else if (hours>100){
- System.out.println("You enter too many hours.");
- }
- else if (dependant>2){
- System.out.println("You enter too many dependants.");
- }
- else if(overtime>=60){
- System.out.println("You enter too many overtime.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement