编译一个计算机(加减乘除)

public static void main(String[] args) {
		// TODO Auto-generated method stubs
		
		Scanner inp=new Scanner(System.in);
		System.out.println("输入一个数");
		int a=inp.nextInt();
		System.out.println("输入一个运算符");
		int b=inp.nextInt();
		System.out.println("输入一个数");
		int c=inp.nextInt();
		
		switch (b) {
		case 1:
			System.out.println(a+"+"+c+"="+(a+c));
			break;
		case 2:
			System.out.println(a+"-"+c+"="+(a-c));
			break;
		case 3:
			System.out.println(a+"*"+c+"="+(a*c));
			break;
		case 4:
			System.out.println(a+"/"+c+"="+(a/c));
			break;
	
		default:
			System.out.println("当前计算机还没有完善,请尽情等待");
			break;
		}

	}

 

你可能感兴趣的:(Java题目)