Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: NEED HELP ASAP PLEASE!!!

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default NEED HELP ASAP PLEASE!!!

    am from the u.k and a newbie to java and i need to create a Body Mass Index Calculator....ive been trying for awhile going through java books but can't seem to get it right....can any one please create a BMI calculator which is really simple and shows weight status table. i have to create this table using Jpad pro....only the javascript code is required so it works without errors when compiled on Jpad pro.

    i managed to create this as simple as i can i have ONE ERROR...
    public class BMI
    {
     
    public static void main(String[] args) {
    int weight; //weight
    int height; //height
    int BMI; //BMI
    char Overweight=0; //Overweight
    char Normal_Weight=0; //Normal Weight
    char Underweight=0; //Underweight
    Scanner input = new Scanner(System.in);
     
    System.out.print("Enter the weight: ");
    weight = input.nextInt();
    System.out.print("Enter the height: ");
    height = input.nextInt();
    input.close();
     
    BMI = weight / height;
    System.out.println("BMI (Body Mass Index): " + BMI);
    if (BMI >= 25 ) {
    BMI = Overweight;
    System.out.print("BMI = ");
    }
    }
    if anyone can make it any more simple then please do....and also add the the weight status table if its possible

    thhanx in advance!
    Last edited by helloworld922; August 12th, 2010 at 08:47 AM.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: NEED HELP ASAP PLEASE!!!

    where is the error?

    For starters, I think you are missing a bracket at the end, but I'm not sure.

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP ASAP PLEASE!!!

    Quote Originally Posted by aussiemcgr View Post
    where is the error?

    For starters, I think you are missing a bracket at the end, but I'm not sure.
    Compiling H:\New Folder (3)\dhondhuuuuuuuuuuuuuuuuuu\BMI.java
    The current directory is: H:\New Folder (3)\dhondhuuuuuuuuuuuuuuuuuu
    Command line: "C:\Java\jdk1.6.0_14\bin\javac.exe" -deprecation -g -classpath H:\NEWFOL~3\DHONDH~1 "H:\New Folder (3)\dhondhuuuuuuuuuuuuuuuuuu\BMI.java"
    H:\New Folder (3)\dhondhuuuuuuuuuuuuuuuuuu\BMI.java:32: reached end of file while parsing
    }
    ^
    1 error
    Finished

    if i put another bracket at the end it creates 2 more errors :-S

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: NEED HELP ASAP PLEASE!!!

    You need to put that bracket at the end. Always make sure every parenthesis/bracket/square bracket has a matching mate (the exception being inside of comments or strings).

    Less errors is not always an indication that you're making progress in making your program work as intended. post the details on these other errors you are getting.

    Also, make sure to surround your code with [highlight=Java]// code goes here[/highlight].

  5. #5
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: NEED HELP ASAP PLEASE!!!

    You were missing a bracket and I'm assuming that your forgot to import Java.util.Scanner;
    Once I added both of those the code worked for me.
    import java.util.Scanner;
     
    public class BMI {
       public static void main(String[] args) {
          int weight; //weight
          int height; //height
          int BMI; //BMI
          char Overweight=0; //Overweight
          char Normal_Weight=0; //Normal Weight
          char Underweight=0; //Underweight
          Scanner input = new Scanner(System.in);
     
          System.out.print("Enter the weight: ");
          weight = input.nextInt();
          System.out.print("Enter the height: ");
          height = input.nextInt();
          input.close();
     
          BMI = weight / height;
          System.out.println("BMI (Body Mass Index): " + BMI);
     
          if (BMI >= 25 ) {
             BMI = Overweight;
             System.out.print("BMI = ");
          }
       }
    }
    Last edited by Brt93yoda; August 12th, 2010 at 10:23 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP ASAP PLEASE!!!


  7. #7
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: NEED HELP ASAP PLEASE!!!

    Whats cross posting do?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP ASAP PLEASE!!!

    Cross posting lets people waste time answering questions that have been answered already on another forum.

  9. #9
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: NEED HELP ASAP PLEASE!!!

    Cross posting is posting your question on multiple forums. This can lead to the same question being answered independently on both forums, wasting people's time. Different forums have different rules regarding cross posting.

    Here at JavaProgrammingForums.com, we're not against cross-posting, however we do ask that you do post links to these other sites so the discussion can be coherent and connected between the two different forums.

Similar Threads

  1. Need a calandar app done asap
    By gixmo in forum Paid Java Projects
    Replies: 6
    Last Post: July 10th, 2010, 08:58 PM
  2. Recursion Problem Need Help ASAP
    By Delstateprogramer in forum Algorithms & Recursion
    Replies: 6
    Last Post: June 26th, 2010, 08:36 PM
  3. Need simple JAVA program fixing ASAP
    By theviper in forum Paid Java Projects
    Replies: 1
    Last Post: April 14th, 2010, 10:59 AM
  4. [SOLVED] find the position of the field separator in the String---need help ASAP
    By rajesh.mv in forum Java Theory & Questions
    Replies: 6
    Last Post: August 17th, 2009, 10:33 AM
  5. Replies: 1
    Last Post: April 1st, 2009, 02:47 PM