Discuss / Java / 交作业

交作业

Topic source

CarlisWang

#1 Created at ... [Delete] [Delete and Lock User]

import java.util.Scanner;

public class Weight {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.print("Input your name:");

        String name = scanner.nextLine();

        System.out.print("Input your weight:");// weight 91.3

        double weight = scanner.nextDouble(); 

        System.out.print("Input your height:");// height  1.78

        double height = scanner.nextDouble(); 

        double ibm = weight/(height*height);

        System.out.println(ibm);

        if(ibm < 18.5){

            System.out.printf("hey , %s , Your weight is too simple .",name);

        }else if(ibm >=18.5 && ibm < 25.0){

            System.out.printf("hey , %s , Your weight is okey .",name);

        }else if(ibm >=25.0 && ibm <= 32.0){

            System.out.printf("hey , %s , Your weight is fat .",name);

        }else if(ibm > 32.0){

            System.out.printf("hey , %s , Your weight is too fat .",name);

        }else{

            System.out.print("Sorry , Maybe your input has something wrong .");

        }

        scanner.close();

    }

}


  • 1

Reply