import java.util.*;
public class Test {
public static void main(String[] argv){
Scanner sc = new Scanner(System.in);
double jieguo = 0;
System.out.print("请输入第一个数字:");
double num1 = sc.nextDouble();
System.out.print("\n请输入第二个数字:");
double num2 = sc.nextDouble();
System.out.print("\n请输入运算符号:");
String fuhao = sc.next();
jisuan js = new jisuan();
if(fuhao.equals("+")){
jieguo = js.jiafa(num1,num2);
System.out.println(jieguo);
}else if(fuhao.equals("-")){
jieguo = js.jiafa(num1, num2);
System.out.println(jieguo);
}else if(fuhao.equals("*")){
jieguo = js.chengfa(num1, num2);
System.out.println(jieguo);
}else if(fuhao.equals("/")){
jieguo = js.chufa(num1, num2);
System.out.println(jieguo);
}else{
System.out.println("您输入的符号不存在");
}
}
}
class jisuan{
public double jiafa(double num1,double num2){
double jieguo = num1+num2;
return jieguo;
}
public double jianfa(double num1,double num2){
double jieguo = num1+num2;
return jieguo;
}
public double chengfa(double num1,double num2){
double jieguo = num1+num2;
return jieguo;
}
public double chufa(double num1,double num2){
double jieguo = num1+num2;
return jieguo;
}
}
如果你还需要封装属性的话.. 请百度Hi我...我会继续的给你搞定...