Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有人能帮我解释一下为什么我的绳子坏了吗?_Java_String - Fatal编程技术网

Java 有人能帮我解释一下为什么我的绳子坏了吗?

Java 有人能帮我解释一下为什么我的绳子坏了吗?,java,string,Java,String,任何帮助都是很棒的家伙!这是一个学校项目,上面写着“热”没有初始化您必须在代码中修复3行: 1.您忘记对项目进行注释 //加热这些物品 你忘了在hot后面加引号了!" 您忘了在单词“请”前加上加号和引号。您需要加上加号才能将字符串分为两行: System.out.println(“警告:超过四个项目太热!” 你的问题是什么?什么不起作用,预期的结果是什么?我需要为我的代码使用一个开关,它告诉我在代码的最后一行“heat”"是否未初始化可能是您的注释//的第二行要求用户输入要加热的项目量和加热项目

任何帮助都是很棒的家伙!这是一个学校项目,上面写着“热”没有初始化

您必须在代码中修复3行:

1.您忘记对项目进行注释
//加热这些物品

  • 你忘了在hot后面加引号了!"

  • 您忘了在单词“请”前加上加号和引号。您需要加上加号才能将字符串分为两行:

  • System.out.println(“警告:超过四个项目太热!”


    你的问题是什么?什么不起作用,预期的结果是什么?我需要为我的代码使用一个开关,它告诉我在代码的最后一行“heat”"是否未初始化可能是您的注释
    //的第二行要求用户输入要加热的项目量和加热项目的时间量
    不是注释,事实上,以:
    加热项目
    开头的行正在作为代码处理?我想
    加热项目
    是未注释的h是一个问题在您的
    案例4
    切换语句之后,您还缺少一个
    中断
    。这是故意的吗?
    public static void main(String[] args)
     {
    // declares variables
    int items, time;
    double heat, h1, h2, h3, h4;
    h1 = 1.00;
    h2 = 1.25;
    h3 = 1.50;
    h4 = 2.00;
    
      Scanner num  = new Scanner(System.in);
    
     // asks user to input the amount of items to heat and the amount of time to 
    heat the items      
      System.out.println("Select number of items being heated");
      items = num.nextInt();
      System.out.println("Select amount of time in seconds to heat one item");
      time = num.nextInt();
    
        // gets user to re-enter the amount of items to less than 5  
        while (items > 4)
        {
                System.out.println("warning: more than four items is too hot! 
    \nplease enter a number below 5");
            items = num.nextInt();
    }
    //heating calculations
        switch (items)
        {
    case 1:
                heat = h1;
        break;
        case 2:
                heat = h2;
        break;
    
        case 3:
    
                heat = h3;
        break;
        case 4:
            heat = h4;
    default:
        heat = 1;
            }
    
            // outputs the total time
            System.out.println("Time: " + time * heat * items + " seconds");
    
     }
     }
    
                    + "\nplease enter a number below 5");