| 123456789101112131415161718192021222324252627282930 |
- /**
- * @author WanJl
- * @version 1.0
- * @title HomeWork05
- * @description 7月14日课后作业-简易计算器
- * @create 2026/7/15
- */
- public class HomeWork05 {
- public static void main(String[] args) {
- int a=15,b=20;
- char operator='/';
- if (operator=='+'){
- System.out.println(a+b);
- }else if (operator=='-'){
- System.out.println(a-b);
- }else if (operator=='*'){
- System.out.println(a*b);
- }else if (operator=='/'){
- if (b==0){
- System.out.println("除数不能为0");
- }
- System.out.println(a/b);
- }else if (operator=='%'){
- if (b==0){
- System.out.println("除数不能为0");
- }
- System.out.println(a%b);
- }
- }
- }
|