I am having trouble figuring out why the output is all 0 instead of the respective user input. I have set every variable to static so it can be used everywhere. What I am confused about is the random 0 that comes out of nowhere.
static int hours,payrate,id;
static double grosspay;
static Scanner sc = new Scanner(System.in);
public static void readInput(int hours,int payrate,int id,Scanner sc)
{
if (id != -1)
{
System.out.println("Employees id : ");
id = sc.nextInt();
System.out.println("The number of hours worked is : ");
hours = sc.nextInt();
System.out.println("The standard payrate is : ");
payrate = sc.nextInt();
}
else
return;
}
public static double computePay(int hours,double grosspay,int payrate)
{
if(hours <= 160)
grosspay = hours * payrate;
else
grosspay = 160 * payrate + (hours - 160) * 1.5 * payrate;
return grosspay;
}
public static void Output(double grosspay,int id)
{
System.out.println("For Employee id " + id + ", grosspay is " + grosspay);
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
readInput(hours,payrate,id,sc);
System.out.println("Grosspay is: " + computePay(hours,grosspay,payrate));
Output(grosspay,id);
System.out.println(id);