小编Lan*_*nce的帖子

Java:这段代码有什么问题?

public static void main(String[] args) {
    // TODO code application logic here
    Scanner input = new Scanner(System.in);
    do{
        System.out.print("Enter choice:");
        int choice;
        choice = input.nextInt();
        switch (choice) 
        {
            case 1: 
                FirstProject.areaRectangle();
                break;
            case 2:
                FirstProject.areaTriangle();
                break;
            default:
                System.out.println("lol");
                break;
        }
    }while (input.nextInt()!=0);    
}




public static void areaRectangle() {
    Scanner input = new Scanner(System.in);
    System.out.println("Area of a rectangle.");

    System.out.print("Enter the width: ");
    double width;
    width = input.nextInt();

    System.out.print("Enter the height: ");
    double height;
    height = input.nextInt();

    double areaRectangle = (width * …
Run Code Online (Sandbox Code Playgroud)

java

-3
推荐指数
1
解决办法
165
查看次数

标签 统计

java ×1