switch语句

// app5_10,switch语句
public class app5_10
{
public static void main(String args[])
{
int a=100,b=7;
char oper='/';

switch (oper)
{
case '+':
// 输出a+b
System.out.println(a+
"+"+b+"="+(a+b));
break;
case '-':
// 输出a-b
System.out.println(a+
"-"+b+"="+(a-b));
break;
case '*':
// 输出a*b
System.out.println(a+
"*"+b+"="+(a*b));
break;
case '/':
// 输出a/b
System.out.println(a+
"/"+b+"="+((float)a/b));
break;
default:
// 输出字符串
System.out.println(
"Unknown expression!!");
}
}
}
lunzi   2005-05-02 03:19:40 评论:0   阅读:1134   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog