日期:2014-05-20 浏览次数:20687 次
import java.util.Scanner;
public class T1226 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
Calculate c=new Calculate();
System.out.println("第一个数");
float num1=s.nextFloat();
System.out.println("第二个数");
float num2=s.nextFloat();
System.out.println(num1+"+"+num2+"="+c.add(num1,num2));
System.out.println(num1+"-"+num2+"="+c.minus(num1, num2));
System.out.println(num1+"*"+num2+"="+c.multiply(num1, num2));
System.out.println(num1+"/"+num2+"="+c.divide(num1, num2));
}
public class Calculate{
public float add(float i,float j){
return i+j;
}
public float minus(float i,float j){
return i-j;
}
public float multiply(float i,float j){
return i*j;
}
public float divide(float i,float j){
return i/j;
}
}
}
Calculate c= new T1226().new Calculate();
Calculate c= new T1226().new Calculate();