I'm new to java and i am trying to make the scanner function work, but it won't. I have the latest version of java and Mac OS X
This is the info on the version that terminal gave me:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)
I compiled this program with jEdit and it reports no errors. But when I run it it gets stuck in a loop.
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
String name;
int hours;
double payRate;
double grossPay;
Scanner keyboard = new Scanner(System.in);
System.out.print("What is your name? ");
name = keyboard.nextLine();
System.out.print("How many hours do you work a week? ");
hours = keyboard.nextInt();
System.out.print("What is your hourly wage? ");
payRate = keyboard.nextDouble();
grossPay = hours * payRate;
System.out.println("Hello" + name);
System.out.println("Your gross pay is $" + grossPay);
}
}
Please Help