Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    i need help, i am stuck

    I am working on a body mass index calculator....everything compiles cleanly except for my BMIndexCalculatorMain class.....it says it cannot find symbol constructor BMIndexCalculator (int, double, double). I don't know what to do to fix it, I'm new at Java. Any help would be appreciated! Thank you.



    /** ---------------------------------------------------------------------
    Description: Generic BMIndex class that calculates the Body Mass Index and has no I/O.<br>
    */
    import javax.swing.*;
    import java.text.*;

    class BMIndex {

    //Data members /**Data members*/
    private int age;
    private double weight;
    private double height;


    //Constructor /**Constructor*/
    public BMIndex (int inputage, double inputweight, double inputheight) {
    setAge (inputage);
    setWeight(inputweight);
    setHeight(inputheight);
    }


    //Set age
    /**@param sets age, weight, height*/
    public void set
    Age (int inputage) {
    age = inputage;
    }


    //Set weight
    public void setWeight(double inputweight) {
    weight = inputweight;
    }


    //Set height
    public void setHeight (double inputheight) {
    height = inputheight;
    }


    /**@return returns age, weight, height*/

    //Return age
    public int getAge () {
    return age;
    }

    //Return weight
    public double getWeight () {
    return weight;
    }

    //Returns height
    public double getHeight () {
    return height;
    }
    }




    /** ---------------------------------------------------------------------
    * Description: Does I/O, uses an instance of the BMIndex class, contains a start method.<br>

    */

    import javax.swing.*;
    import java.util.*;
    import java.text.*;

    /**define main class & method*/
    class BMIndexCalculator {

    //Main method
    public static void main(String [] args) {


    /**Get the four input values*/
    //Get the four input values
    int age;
    double weight, height, bMI;
    String inputStr;


    inputStr = JOptionPane.showInputDialog (null, "Enter your Age: ");
    age = Integer.parseInt(inputStr);

    inputStr = JOptionPane.showInputDialog (null, "Enter Height (inches): ");
    height = Double.parseDouble(inputStr);

    inputStr = JOptionPane.showInputDialog (null, "Enter Weight (lbs): ");
    weight = Double.parseDouble(inputStr);



    /**Use DecimalFormat to change number of decimal places displayed*/
    DecimalFormat df = new DecimalFormat("0.00");



    //convert weight in lbs to weight in kilograms
    weight = weight * 2.2;



    //convert height in cm to height in meters
    height = height/100;

    BMIndex calc = new BMIndex (age, weight, height);



    /**Display input values and computed results using PrintStream*/
    //Displays the input values and results

    bMI= weight/Math.pow(height, 2);

    System.out.println ("Weight: " + calc.getWeight() + " kilograms.");
    System.out.println ("Height: " + df.format(calc.getHeight()) + " cm");
    System.out.println ("BMI: " + bMI * 100);

    }
    }


    /** ---------------------------------------------------------------------
    * Description: Makes an instance of the BMIndexCalculator class and contains a start method.<br>
    *
    */

    import javax.swing.*;
    import java.util.*;
    import java.text.*;

    /**define main class & method*/
    class BMIndexCalculatorMain {

    //Main method
    public static void main(String [] args) {
    BMIndexCalculator calc = new BMIndexCalculator ();
    calc.start();
    }


    /**Get the input values*/
    //Get the input values
    int age;
    double height, weight, recWeight;
    String inputStr;



    /**Use DecimalFormat to change number of decimal places displayed*/
    DecimalFormat df = new DecimalFormat("0");

    BMIndexCalculator calc = new BMIndexCalculator (age, weight, height);

    /**Display input values and computed results using JOptionPane*/
    //Displays the input values and results


    //Convert height in inches to centimeters

    height = height*2.54;

    recWeight= ((height - 100) + age%10) * 0.90;


    JOptionPane.showMessageDialog
    (null, "The recommended weight for your height and age is: " + df.format(recWeight*2.2) + " lbs");
    }
    }

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    parameters (and names, functions, id's ... as well) must have not empty spaces as inner charachters and, if strings, must not have a number or some of the special characters as first character.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't know what that means.......i'm new to java

  • #4
    New Coder
    Join Date
    Feb 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know much Java either, but this is a JavaScript forum. You would probably get more help if you posted to the Computer Programming forum.
    Asp.Net 1.1 - 20 hrs
    CSS 2.0 - 3 hrs
    XHTML 1.1 - 5hrs
    JavaScript - 5hrs
    Cross-Browser Compatibility - Priceless

  • #5
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Java != JavaScript

    Different programming languages altogether

    http://en.wikipedia.org/wiki/Javascript

    http://en.wikipedia.org/wiki/Java_programming_language
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


  •  

    Posting Permissions

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