关注重工黑大帅,学习不迷路
一、利用面向过程编程思想完成计算机简单四则运算功能
package practice;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Operation o = new Operation();
o.fun();
}
}
class Operation{
Scanner scanner = new Scanner(System.in);
public void add() {
System.out.println("你选择的是加法");
System.out.print("请输入第一个数:");
int x = scanner.nextInt();
System.out.print("请输入第二个数:");
int y = scanner.nextInt();
System.out.println("所求结果为:"+(x+y));
}
public void sub() {
System.out.println("你选择的是减法");
System.out.print("请输入第一个数:");
int x = scanner.nextInt();
System.out.print("请输入第二个数:");
int y = scanner.nextInt();
System.out.println("所求结果为:"+(x-y));
}
public void mul(