Results 1 to 4 of 4
Thread: SWing;* ISsue dial dialogbox
- 11-29-2010, 06:17 PM #1
Member
- Join Date
- Nov 2010
- Location
- Virginia
- Posts
- 14
- Rep Power
- 0
SWing;* ISsue dial dialogbox
I am trying to write a program where we calculate the number of calories needed each day for an active man or women by knowing the weight, height, and age. My program should be interactive with the user ask question to determine if the user is man or woman.
but for some reason I am not able to run this program. I am gonna past my code. If someone could look @ them closely, and tell me what I have to fix.
import javax.swing.*;
public class takehome2
{
public static void main ( String [] args)
throws java. io.IOExeception
{
String W,H,A;
double x,y,z,k1,k2;
G= JOptioonPane.showInputDialog (" enter gender:");
W= JOptionPane. showInputDialog("enter weight:");
H= JOptionPane. showInputDialog("enter height:");
A= JOptionPane. showInputDialog("enter Age:");
x= Double. parseDouble (W);
y= Double. parseDouble (H);
A= Double. parseDouble (A);
k1= 19.18W+7H-9.52A+92.4
k2= 9.7+6(W+H-A)
double largenum;
if (G==male)
largenum=k1
JOptionPane.showMessageDialog(null," Your calorie needed everyday is: "+k1,"calorie", JOptionPane. INFORMATION_MESSAGE);
else
largenum=k2
JOptionPane.showMessageDialog(null," Your calorie needed everyday is: "+k2,"calorie", JOptionPane. INFORMATION_MESSAGE);
System.exit(0);
}
}
- 11-29-2010, 06:53 PM #2
What problems are you having? Compiler errors? What are they? Generally, they tell you exactly what's wrong.
You probably want to use more descriptive variable names, that way it's easier for other people to read your code. Also, don't forget to use the code tags when posting code to preserve formatting.
For starters, what is the male variable? Did you want that to be a String: "male"? If so, you should use .equals(), not ==.
- 11-29-2010, 07:14 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 63
- Rep Power
- 0
Lots of errors.
JOptioonPane -> JOptionPane
G is not declared.
a= Double.parseDouble (A); instead of A = ....
You use strings in the arithmetic expressions.
Look up the syntax for multiplication.
You need semicolons after each statement.
Look at the compiler error messages for clues.
- 11-29-2010, 10:52 PM #4
Member
- Join Date
- Nov 2010
- Location
- Virginia
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
AWT/Swing Mixing Still and issue on MAC OSX?
By Confused in forum AWT / SwingReplies: 2Last Post: 02-21-2010, 08:34 PM -
Swing Timers Issue.
By killpoppop in forum AWT / SwingReplies: 4Last Post: 03-09-2009, 11:17 PM -
[SOLVED] Swing Timer issue
By Doctor Cactus in forum New To JavaReplies: 6Last Post: 03-03-2009, 12:25 PM -
[SOLVED] swing dialogbox size
By MK12 in forum New To JavaReplies: 26Last Post: 02-13-2009, 05:08 PM -
Java1.5 Swing Issue
By naveenbk in forum AWT / SwingReplies: 1Last Post: 11-23-2008, 08:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks