| | |
Java 5 with Mac OS X
![]() |
•
•
Join Date: Sep 2006
Posts: 2
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- General Tips for Mac OS X (Mac tips 'n' tweaks)
- JVM GetLastErrorString Crash - OS X 10.4.7 (Java)
- changing application's LookAndFeel (Java)
- Mac Newbie - IE and WMP on Mac? (OS X)
- A great java game. (Geeks' Lounge)
- PC Guy that wants a Mac (Mac Rumors and Reports)
- C++ is dying a slow death (C++)
- IDE for Java? (Mac Software)
Other Threads in the Java Forum
- Previous Thread: Java holiday system not working...
- Next Thread: Artificial intelligence-Hopefield network
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card chat class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting scanner se server service set sms socket software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows






