System.in.read();返回的是整数int类型,赋给类型char的变量就回出现上述问题建议改为
c=(char)System.in.read();

解决方案 »

  1.   

    package untitled4;import java.io.*;public class Untitled1 {
      public static void main(String[] args) {
      int a,b;
      char c;
       System.out.println("input number+char+number:");
       a=(int)System.in.read();
       c=(char)System.in.read();
       b=(int)System.in.read();
        switch(c)
       {
       case'+':System.out.println(a+b);break;
       case'-':System.out.println(a-b);break;
       case'*':System.out.println(a*b);break;
       case'/':System.out.println(a/b);break;
       }
      }
    }
    "Untitled1.java": Error #: 360 : unreported exception: java.io.IOException; must be caught or declared to be thrown at line 10, column 21
    "Untitled1.java": Error #: 360 : unreported exception: java.io.IOException; must be caught or declared to be thrown at line 11, column 22
    "Untitled1.java": Error #: 360 : unreported exception: java.io.IOException; must be caught or declared to be thrown at line 12, column 21
      

  2.   

    package untitled4;import java.io.*;public class Untitled1 {
      public static void main(String[] args) throws IOException{
      int a,b;
      char c;
       System.out.println("input number+char+number:");
       a=(int)System.in.read();
       c=(char)System.in.read();
       b=(int)System.in.read();
        switch(c)
       {
       case'+':System.out.println(a+b);break;
       case'-':System.out.println(a-b);break;
       case'*':System.out.println(a*b);break;
       case'/':System.out.println(a/b);break;
       }
      }
    }
    就可以了
      

  3.   

    package untitled4;import java.io.*;public class Untitled1 {
      public static void main(String[] args) throws IOException{
      int a,b;
      char c;
       System.out.println("input number+char+number:");
       a=(int)System.in.read();
       c=(char)System.in.read();
       b=(int)System.in.read();
        switch(c)
       {
       case'+':System.out.println(a+b);break;
       case'-':System.out.println(a-b);break;
       case'*':System.out.println(a*b);break;
       case'/':System.out.println(a/b);break;
       }
      }
    }
      

  4.   

    C:\JBuilder6\jdk1.3.1\bin\javaw -classpath "C:\Documents and Settings\carl\jbproject\untitled4\classes;C:\JBuilder6\jdk1.3.1\demo\jfc\Java2D\Java2Demo.jar;C:\JBuilder6\jdk1.3.1\jre\lib\i18n.jar;C:\JBuilder6\jdk1.3.1\jre\lib\jaws.jar;C:\JBuilder6\jdk1.3.1\jre\lib\rt.jar;C:\JBuilder6\jdk1.3.1\jre\lib\sunrsasign.jar;C:\JBuilder6\jdk1.3.1\lib\dt.jar;C:\JBuilder6\jdk1.3.1\lib\htmlconverter.jar;C:\JBuilder6\jdk1.3.1\lib\tools.jar"  junit.textui.TestRunner 
    java.lang.NoClassDefFoundError: junit/textui/TestRunnerException in thread "main"
      

  5.   

    package 在这里有用吗?把它去掉。import java.io.*;public class Untitled1 {
      public static void main(String[] args) throws IOException{
      int a,b;
      char c;
       System.out.println("input number+char+number:");
       a=(int)System.in.read();
       c=(char)System.in.read();
       b=(int)System.in.read();
        switch(c)
       {
       case'+':System.out.println(a+b);break;
       case'-':System.out.println(a-b);break;
       case'*':System.out.println(a*b);break;
       case'/':System.out.println(a/b);break;
       }
      }
    }