用JAVA代码运行简单的四则运算
2017-03-07 22:05 高小小小帅 阅读(512) 评论(0) 编辑 收藏 举报代码部分:
public class practice {
public static void main(String[] args) {
int b;
for (int i = 0; i <= 300; i++) {
int a = (int) (Math.random() * 100);
b = (int) (Math.random() * 100);
if (b != 0) {
System.out.println(a + "/" + b + "=" + (a / b));
System.out.println("商取整数!");
} else {
System.out.println("被除数不能为0");
}
System.out.println(a + "+" + b + "= " + (a + b));
System.out.println(a + "-" + b + "= " + (a - b));
System.out.println(a + "*" + b + "= " + (a * b));
}
}
}
运行结果: