Program is supposed to calculate persons BMI import java.util.scanner; public cl
ID: 3647463 • Letter: P
Question
Program is supposed to calculate persons BMIimport java.util.scanner;
public class BMI{
public static void main(String args[]){
Scanner input=Scanner(System.in);
//Declaring variables for height and weight
double height;
double weight;
//prompting for input
System.out.print("Enter Height in Meters : ");
height=input.nextDouble();
System.out.print("Enter Weight in Kilograms : ");
weight=input.nextDouble();
double BMI;
//Calculating BMI
BMI=weight/(height*height);
System.out.println(" Your BMI is: "+BMI);
}
}
Explanation / Answer
please rate - thanks
I've highliged the 2 lines that had errors. both had to do with Scanner
import java.util.Scanner;
public class BMI{
public static void main(String args[]){
Scanner input= new Scanner(System.in);
//Declaring variables for height and weight
double height;
double weight;
//prompting for input
System.out.print("Enter Height in Meters : ");
height=input.nextDouble();
System.out.print("Enter Weight in Kilograms : ");
weight=input.nextDouble();
double BMI;
//Calculating BMI
BMI=weight/(height*height);
System.out.println(" Your BMI is: "+BMI);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.