package 第四章;
import java.io.EOFException;
//filename:App4_3.java
public class App4_3 //定义一个公共类App4_3{ public static void main(String[] args) throws Exception { int a=100,b=6; //定义一个整型常量a=100,b=6 char oper; //定义一个字符型常量oper System.out.print("请输入运算符:"); //输出“请输入运算符” oper=(char)System.in.read(); //强制类型转换 switch (oper) { case '+': System.out.println(a+"+"+b+"="+(a+b)); break; //终止循环 case '-': System.out.println(a+"-"+b+"="+(a-b)); break; case '*': System.out.println(a+"*"+b+"="+(a*b)); break; case '/': System.out.println(a+"/"+b+"="+((float)a/b)); break; //终止循环 default: //输出字符串 System.out.println("输入的符号不正确!"); //输出“输入的符号不正确!” } }}