Problem - ArithmeticOperations

Write a Java program that prompts the user to enter two integers, and then displays the sum, difference, product, and quotient of the two numbers. Use a method to perform the calculation and display the results.

Hints: prompts and enter from keyboard

import java.util.Scanner; // 引入Java提供的接收从键盘输入的类

public class InputFromKeyboard {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);   // 用Scanner类创建一个它的对象,用来接收输入
		
		System.out.print("Input the first integer: ");  // 给用户的提示信息
		int firstInt = scanner.nextInt();   // 接收第一个输入,是一个整数,并将值赋给firstInt变量
		
		System.out.print("Input the second integer: ");
		int secondInt = scanner.nextInt();  // 

		scanner.close(); // 关闭scanner
        // 模板化输出,这里 %d 是整数的占位符(即%d这个位置需要一个整数填充)
		System.out.printf("User input two integers: %d and %d.\n", firstInt, secondInt);
	}
}

Solution