Im am trying to write a Java program with a system class called:PayScale.
1. It needs to prompt user for "Hours worked" and "Pay rate"
2. Determine if there is overtime
3. Calculate overtime at "time and 1/2"
4. Calculate regular pay
It must then print out:
1. Total hours worked
2. Regular hours
3. Overtime hours
4. Pay rate
5. Regular pay
6. Overtime pay
7. Total pay
I must also format the pay as currency and build in an exit key.
I have been trying for hours on end and cannot seem to solve. This is what I have so for:
import java.io.*;
public class PayScale
{
public static void main(String [] args) throws IOException
{
int input, sumA, sumB, sumC, sumD, sumF, sumG, sumH;
sumA=0;
sumB= 40;
sumC=sumA - 40;
sumD=sumF=sumG=sumH=0;
System.out.print("please enter your total hours worked [0 to exit] : ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
input = Integer.parseInt(br.readLine());
if(input==0) System.exit(1);
while(input != 0)
{
if(input <= 40)
{
System.out.println(input + " hours");
}
if(input > 40)
{
sumB++;
System.out.println(input +" hours");
}
if (input > 40)
{
sumC++;
System.out.println(input +" hours");
}
System.out.print("Please enter your pay rate[0 to exit]:");
input = Integer.parseInt(br.readLine());
}
System.out.println("The total number of hours worked is " + sumA );
System.out.println("The total number of regular hours worked is " + sumB );
System.out.println("The total number of overtime hours worked is " + sumC );