Results 1 to 4 of 4
  1. #1
    eppoair2 is offline Member
    Join Date
    Nov 2010
    Location
    Virginia
    Posts
    14
    Rep Power
    0

    Default 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);
    }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default

    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 ==.

  3. #3
    hosscomp is offline Member
    Join Date
    Oct 2010
    Posts
    63
    Rep Power
    0

    Default

    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.

  4. #4
    eppoair2 is offline Member
    Join Date
    Nov 2010
    Location
    Virginia
    Posts
    14
    Rep Power
    0

    Default

    Thanks all for your help. I will try your feedback once I got off from work :)

Similar Threads

  1. AWT/Swing Mixing Still and issue on MAC OSX?
    By Confused in forum AWT / Swing
    Replies: 2
    Last Post: 02-21-2010, 08:34 PM
  2. Swing Timers Issue.
    By killpoppop in forum AWT / Swing
    Replies: 4
    Last Post: 03-09-2009, 11:17 PM
  3. [SOLVED] Swing Timer issue
    By Doctor Cactus in forum New To Java
    Replies: 6
    Last Post: 03-03-2009, 12:25 PM
  4. [SOLVED] swing dialogbox size
    By MK12 in forum New To Java
    Replies: 26
    Last Post: 02-13-2009, 05:08 PM
  5. Java1.5 Swing Issue
    By naveenbk in forum AWT / Swing
    Replies: 1
    Last Post: 11-23-2008, 08:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •