Results 1 to 4 of 4
- 10-22-2010, 02:34 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 3
- Rep Power
- 0
Please look at my java code and tell me what's wrong
public class Two {
public static void main(String[] args) {
int hr = Integer.parseInt (JOptionPane.showInputDialog("Enter hourly rate of pay"));
int worked = Integer.parseInt (JOptionPane.showInputDialog("Enter number of hours worked"));
if (worked>=40)
System.out.println(hr*worked*1.5);
else
System.out.println(hr*worked);
}
my problem with the code above is that whenever I put decimal numbers, the system stops. For example, 7.5
-
It doesn't just stop, the code will throw a NumberFormatException (note, when you have a question about errors, please inform us of all exceptions or error messages you receive as well as indicate which line causes the exception). If you want to catch and handle the exception, then read the Java tutorials exception section, especially the section on try/catch.
- 10-22-2010, 04:14 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 3
- Rep Power
- 0
Fubarable, where can I find thee Java tutorials exception section?
Can anyone tell me how to fix the NumberFormatException error
- 10-22-2010, 04:15 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
What is wrong with my code?!
By new2java2009 in forum New To JavaReplies: 2Last Post: 04-17-2010, 08:01 PM -
what wrong with my java code
By MAXZZXAM in forum New To JavaReplies: 3Last Post: 11-19-2009, 09:38 AM -
Need help! something wrong in my code
By novak100 in forum New To JavaReplies: 2Last Post: 11-18-2009, 11:59 PM -
pls tell wat wrong with my code???
By low224 in forum New To JavaReplies: 13Last Post: 01-11-2009, 07:40 AM -
what is wrong with this code
By masaka in forum New To JavaReplies: 5Last Post: 04-16-2008, 08:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks