Answer:
import java.util.Scanner;
public class num4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please enter two numbers");
int a = in.nextInt();
int b = in.nextInt();
//addition operation
System.out.println("The sum of a + b is: "+(a+b));
//substration operation
System.out.println("The difference of a - b is: "+(a-b));
//multiplication operation
System.out.println("The product of a and b is: "+(a*b));
//division operation
System.out.println("The integer division of a by b is: "+(a/b));
//exponents operation
System.out.println("a raised to the power of b is: "+Math.pow(a,b));
}
}
Explanation:
In the program above written in Java;
The User is prompted for two numbers, these are saved as ints a,b
Then a calculation is carried out for each of the basic operations
addition a+b
subtraction a-b
multiplication a*b
division a/b
exponents a^b
The results of the operations are printed to the console