import java.util.*;
public class GoalsErrors
{
public static void main(String [] args)
{
int goals,errors;
System.out.println("Enter two number:");
Scanner keyboard = new Scanner(System.in);
goals = keyboard.nextInt();
errors = keyboard.nextInt();


if ((goals > 10) || (errors=0))
System.out.println("Wow!");
else
    System.out.println("Oh well");
    
    
}
}cmd提示||不能应用于boolean,int我的原意是想goals>10,且errors=0时,输出“wow!”,否则,输出“oh well”怎么改嘎?这是《java程序设计与问题解决基础篇》上的题

解决方案 »

  1.   

    import java.util.*;
    public class GoalsErrors
    {
    public static void main(String [] args)
    {
    int goals,errors;
    System.out.println("Enter two number:");
    Scanner keyboard = new Scanner(System.in);
    goals = keyboard.nextInt();
    errors = keyboard.nextInt();


    if ((goals > 10) || (errors=0))
    System.out.println("Wow!");
    else
        System.out.println("Oh well");
        
        
    }
    }
      

  2.   

    errors=0
    你这是赋值
    改成errors==0
      

  3.   

    if ((goals > 10) || (errors=0))
    应该是:if ((goals > 10) || (errors==0))
    少了个等号的
      

  4.   

    这比较运算符这样写”errors=0“。真让人蛋疼!
      

  5.   

    if判断的时候是boolean型的,可是你的那个errors=0是赋值,要比较的话是errors==0,这样用才对!
      

  6.   

    errors=0 ?低级错误不应该呀
      

  7.   

    if ((goals > 10) || (errors=0))
      

  8.   

    谢谢dalor,谢谢zyksun,and 各位。刚学习,我以后会注意的。不过我还要搞清楚,为什么我发帖时插入代码,怎么会自动改动原格式呢(代码缩进的格式被改成两端对齐了)?
      

  9.   

    想goals>10,且errors=0时
    应该这样写吧:if ((goals > 10) && (errors==0))
      

  10.   

    import java.util.*;
    public class GoalsErrors
    {
    public static void main(String [] args)
    {
    int goals,errors;
    System.out.println("Enter two number:");
    Scanner keyboard = new Scanner(System.in);
    goals = keyboard.nextInt();
    errors = keyboard.nextInt();
    if ((goals > 10) || (errors=0))                 这错了(errors=0)应该为(errors==0)
    System.out.println("Wow!");
    else
    System.out.println("Oh well");
      
      
    }
    }
      

  11.   

    不对啊,这个有2个错误啊。
    你是说要    goals>10,且errors=0时,输出“wow!”,否则,输出“oh well”
      那应该是if(goals>10 && errors == 0){
                  System.out.println("Wow!");
             }else{
                 System.out.println("Oh well");
             }
    应该用&&符号吧?而且 errors 应该是==号  
      

  12.   

    (goals > 10) || (errors==0)
      

  13.   

    SoulDeviler 看得真仔细。我觉得对。谢谢。
      

  14.   

    if ((goals > 10) || (errors == 0))
      

  15.   

    晕死,被忽悠了,errors==0这样改就可以了
      

  16.   

    改成errors==0
     不细心呀