Please help me with this programming problems!!!! >O<?

2009-08-03 1:22 am
A person’s BMI (Body Mass Index) is calculated by dividing the person’s weight (in kilograms) by the square of their height (in metres), then rounding the result to the nearest whole number. A healthy BMI is considered to be within the range 19 to 25.
The CalculateBMI program shown below is supposed to calculate a person’s BMI.
The user enters their weight and height when prompted, and the program then calculates
and displays the user’s BMI.


For example, if the user weighs 61.5 kilograms and is 1.64 metres in height, the output
should look as follows:

Enter your weight in Kilograms: 61.5
Enter your height in Metres: 1.64
Your BMI is: 23

There are 10 errors or omissions in the source code below. Please find and correct it.

// program to calculate Body Mass Index (BMI)
public class CalculateBMI {
public start() {

System.out.println("Enter your weight in Kilograms: ");
int weight = Double.parseDouble(Keyboard.readInput());
System.out.print(Enter your height in Metres: ");
double height = Integer.parseInt(Keyboard.readInput);
double bodyMassIndex = weight / height * height);
System.out.print("Your BMI is: ")
System.out.println(Math.round(BodyMassIndex));
}

回答 (1)

2009-08-06 7:56 pm
✔ 最佳答案
You can find the mistakes in that program by debugging it.

Debugging is a skill every programmer needs to have. I suggest learning it sooner rather than later.

No amount of people answering questions here can replace learning how to debug programs.
參考: Programming since 1970.


收錄日期: 2021-05-01 00:58:57
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090802172254AAnS95o

檢視 Wayback Machine 備份