小编Doh*_*Kik的帖子

循环不执行多次

我应该制作一个程序,不断接受桌面订单数据,并显示超过36英寸长,至少有一个抽屉的橡木书桌的所有相关信息.

import java.util.*;

public class MangMaxB 
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        char ans;
        int orderNum=0, length=0, width=0, numDrawer=0, price=1000;
        String name;

        System.out.print("Do you wish to enter Oak " +
                        "desk order data? (y/n)");
        ans = input.nextLine().charAt(0);

        while (ans != 'n')
        {  
            System.out.print("Enter customer name: ");
            name=input.nextLine();

            System.out.print("Enter order number: ");
            orderNum=input.nextInt();    

            System.out.print("Enter length and width of Oak desk" +
                        " separated by a space: ");
            length = input.nextInt();
            width = input.nextInt();

            System.out.print("Enter number …
Run Code Online (Sandbox Code Playgroud)

java iteration loops while-loop java.util.scanner

1
推荐指数
1
解决办法
254
查看次数

标签 统计

iteration ×1

java ×1

java.util.scanner ×1

loops ×1

while-loop ×1