...

View Full Version : i need help, i am stuck



aa8514
10-18-2005, 05:12 PM
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");
}
}

Kor
10-18-2005, 05:38 PM
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.

aa8514
10-18-2005, 06:00 PM
i don't know what that means.......i'm new to java

jbezweb
10-18-2005, 06:14 PM
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.

martin_narg
10-18-2005, 06:24 PM
Java != JavaScript

Different programming languages altogether

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum