Skip to content

Instantly share code, notes, and snippets.

@Restoration
Last active October 11, 2018 06:55
Show Gist options
  • Select an option

  • Save Restoration/2423947fb95f13e09713ab0c80a64cd7 to your computer and use it in GitHub Desktop.

Select an option

Save Restoration/2423947fb95f13e09713ab0c80a64cd7 to your computer and use it in GitHub Desktop.
cal
import java.util.Scanner;
public class hourlyRate {
public static void main(String[] args) {
String level;
double rate;
int hour;
double income;
double cpp;
double ei;
double netIncome;
rate = 0;
cpp = 0;
ei = 0;
netIncome = 0;
Scanner input = new Scanner(System.in);
System.out.println (" Which hourly rate do you have? please enter number A to E");
level = input.nextLine();
System.out.println (" How many hours you worked?");
hour = input.nextInt();
input.close();
switch(level) {
case "A":
rate = 12.65;
break;
case "B":
rate = 13.65;
break;
case "C":
rate = 14.65;
break;
case "D":
rate = 15.65;
break;
case "E":
rate = 16.65;
break;
default:
System .out.println( "please enter A to E");
}
double overtime;
overtime = 0;
if( hour > 80) {
overtime = (hour -80) * 1.5;
}
income = (hour * rate);
// Get CPP
cpp = Math.round(income * 0.5 );
// GetEI
ei = Math.round(income * 0.2 );
netIncome = income - cpp - ei;
System.out.println ("Your net income is "+netIncome);
System.out.println ("Your gross income is "+income);
System.out.println ("CPP is "+cpp);
System.out.println ("EI is "+ei);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment