|
-
Feb 27th, 2006, 04:40 PM
#1
Thread Starter
Junior Member
One line causing code to fail.
The last line before the exit is causing a problem, as far as I can see, everything is right (calculations, variables, etc...) when you take out the division line, the problem gives you your two numbers, but won't divide them in that line of code, why is that?
Code:
import javax.swing.JOptionPane;
public class Problem2
{
public static void main(String [] args)
{
double integer_one, integer_two;
String number_one, number_two, Product;
number_one = JOptionPane.showInputDialog(null,"Please enter your weekly salary:");
integer_one = Integer.parseInt(number_one);
number_two = JOptionPane.showInputDialog(null,"Please enter your hours worke:");
integer_two = Integer.parseInt(number_two);
JOptionPane.showMessageDialog(null, number_one, "Weekly Salary",JOptionPane.OK_CANCEL_OPTION);
JOptionPane.showMessageDialog(null, number_two, "Hours worked",JOptionPane.OK_CANCEL_OPTION);
JOptionPane.showMessageDialog(null,"Hourly Pay" + integer_one / integer_two ,JOptionPane.OK_CANCEL_OPTION);
System.exit(0);
}
}
Last edited by Squirrel RJ; Feb 27th, 2006 at 08:56 PM.
-
Feb 28th, 2006, 12:03 AM
#2
Re: One line causing code to fail.
Change the last line to:
Code:
JOptionPane.showMessageDialog(null
, "Hourly Pay" + (integer_one / integer_two)
, "Payment", JOptionPane.OK_CANCEL_OPTION) ;
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|