Skip to content

Instantly share code, notes, and snippets.

@jimmy087
Created May 4, 2013 05:42
Show Gist options
  • Save jimmy087/5516348 to your computer and use it in GitHub Desktop.
Save jimmy087/5516348 to your computer and use it in GitHub Desktop.
Simple program which calculates tax and net pay
public class Exercise1 {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter employee name: ");
String employeeName = input.nextLine();
System.out.println("Number of hours worked: ");
int numberOfHoursWorked = input.nextInt();
System.out.println("Hourly wage rate: ");
double wageRate = input.nextDouble();
System.out.println("Enter the Federal tax rate: ");
double federalTaxRate = input.nextDouble();
System.out.println("Enter the state tax rate: ");
double stateTaxRate = input.nextDouble();
double grossPay = wageRate * numberOfHoursWorked;
double federalTax = grossPay * federalTaxRate;
double stateTax = grossPay * stateTaxRate;
double netPay = grossPay - federalTax - stateTax;
System.out.println("Deduction of " + employeeName);
System.out.println("Federal Tax: " + federalTax);
System.out.println("State Tax: " + stateTax);
System.out.println("Net Pay: " + netPay);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment