- import java.util.Scanner;
- public class BMIManagerTest
- {
- /**
- * @param args
- */
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- String yourname;
- float h = 0;
- float w;
- boolean s;
- System.out.println("請輸入您的大名 : ");
- yourname = scan.next();
- while(h == 0)
- {
- try
- {
- System.out.println("請輸入您的身高 : ");
- h = Float.parseFloat(scan.next());
- }
- catch(Exception e)
- {
- System.out.println("請重新輸入數字做為你的身高!");
- }
- }
- System.out.println("請輸入您的體重 : ");
- w = Float.parseFloat(scan.next());
- System.out.println("請輸入您是男生(1)/女生(0) :");
- s = Integer.parseInt(scan.next())==1;
-
- //BMIManager myBMI = new BMIManager(h,w,s);
- BMIManager myBMI = new BMIManager(h,w,s);
- System.out.print(myBMI.calculateBMI()+"\n");
- System.out.print(myBMI.calculateBMI()+"\n");
- System.out.printf("%s",myBMI.suggestion());
-
- /*
- System.out.println("您輸入的大名 :"+yourname);
- System.out.println("您輸入的身高 :"+myBMI.mHeight);
- System.out.println("您輸入的體重 :"+myBMI.getWeight());
- System.out.println("您輸入您是:"+(myBMI.getSex()==true?"男生":"女生"));
- */
-
- }
- }
複製代碼 |