Hey guys, So yea I'm novice at Javascript... Could someone explain to me why the pay variable always returns 0.0?
[CODE]
import java.util.Scanner;
public class shour
{
public static void main(String[] args)
{Scanner scan = new Scanner(System.in);
double xhours = 0;
double xwage = 0;
double xovertime = 0;
double calcover = 3/2;
double pay = (xhours*xwage)+(xovertime*calcover);
System.out.println("Welcome to the wage Calculator, type -1 at the hours input to exit");
System.out.println("Enter the amount of hours the Employee worked this week");
xhours = scan.nextDouble();
System.out.println("Enter the Employees wage");
xwage = scan.nextDouble();
System.out.println("Enter the Employees overtime hours");
xovertime = scan.nextDouble();
System.out.println("That Employees pay is :" + pay);
while (xhours >= 0){
System.out.println("Enter the amount of hours the Employee worked this week");
xhours = scan.nextDouble();
System.out.println("Enter the Employees wage");
xwage = scan.nextDouble();
System.out.println("Enter the Employees overtime hours");
xovertime = scan.nextDouble();
System.out.println("That Employees pay is :" + pay);
}
}
}
[/CODE]
You are calculating pay while xhours, xwage and xovertime are still zero. ( 0 * 0 ) + ( 0 * 1,5 ) = 0
Put the line " double pay = (xhours*xwage)+(xovertime*calcover); " after: " xovertime = scan.nextDouble(); "
Oh and that's java as far as I can see, javascript isn't the same language as java.
[QUOTE=Zeonho;36307204]You are calculating pay while xhours, xwage and xovertime are still zero. ( 0 * 0 ) + ( 0 * 1,5 ) = 0
Put the line " double pay = (xhours*xwage)+(xovertime*calcover); " after: " xovertime = scan.nextDouble(); "
Oh and that's java as far as I can see, javascript isn't the same language as java.[/QUOTE]
Sorry, I didnt mean javascript... I dont know why I said that but THANKS!
Sorry, you need to Log In to post a reply to this thread.