Discuss / Java / 作业

作业

Topic source

package myfirstjava;

import java.util.Scanner;

public class helloworld {

public static void main(String[] args) {

    Scanner scanner=new Scanner(System.in);

    System.out.print("请输入体重");

    double weight=scanner.nextDouble();

    System.out.print("请输入身高");

    double hight=scanner.nextDouble();

    if((weight/(hight*hight))>32) {

    System.out.print("非常肥胖");

    }

    else 

    if((weight/(hight*hight))>28) {

    System.out.print("肥胖");

    }

    else

    if((weight/(hight*hight))>25) {

    System.out.print("过重");

    }

    else

    if((weight/(hight*hight))>18.5) {

    System.out.print("正常");

    }

    else {

    System.out.print("过轻");

    }   

}

}


  • 1

Reply