【程式語言】JAVA的第二堂課 |計算BMI 字串並顯示
Published:
by .
import java.util.*;
class ch3 {
public static void main(String[] aru) {
Scanner myInput = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("##.0");
System.out.println("Hello," + aru[0]);
System.out.print("Your gender:");
String gender = myInput.nextLine();
System.out.print("Your height in meter:");
float height = myInput.nextFloat();
System.out.print("Your weight in kilogram:");
float weight = myInput.nextFloat();
System.out.println("Your BMI is " + df.format((weight)/(height*height)) + "M");
}
}