import java.util.*;
class MyMathTest{
public static void main(String[] args){
MyMath mm = new MyMath();
Scanner sc = new Scanner(System.in);
while (true){
System.out.println("counter!counter!counter!");
System.out.println("Please input the num(without 0):");
int a = sc.nextInt();
if (a == 0)
System.exit(0);
sc.nextLine();
System.out.println("Please input the symbol:");
String symbol = sc.nextLine();
System.out.println("Please input the num too:");
int b = sc.nextInt();
switch (symbol){
case "+":
System.out.println("Add="+mm.add(a,b));
break;
case "-":
System.out.println("Sub="+mm.sub(a,b));
break;
case "*":
System.out.println("Mul="+mm.mul(a,b));
break;
case "/":
System.out.println("Div="+mm.div(a,b));
break;
case "%":
System.out.println("Mod="+mm.mod(a,b));
break;
default:{
System.out.println("Please input the correct symbol,SB!");
}
}
}
}
}
class MyMath{
public int add(int a,int b){
return a+b;
}
public int sub(int a,int b){
return a-b;
}
public int mul(int a,int b){
return a*b;
}
public int div(int a,int b){
return a/b;
}
public int mod(int a,int b){
return a%b;
}
}
|
|