Answer:
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- // Create a Scanner object to get user input
- Scanner input = new Scanner(System.in);
-
- // Prompt user to input first number
- System.out.print("Input first number: ");
- double R = input.nextDouble();
- // Prompt user to input first number
- System.out.print("Input second number: ");
- double T = input.nextDouble();
-
- // Display R and T
- System.out.println("R = " + R);
- System.out.println("T = " + T);
- // Display Sum of R and T
- System.out.println("R + T = " + (R + T));
- // Display Difference between R and T
- System.out.println("R - T = " + (R - T));
- // Display Product of R and T
- System.out.println("R * T = " + (R * T));
- }
- }
Step-by-step explanation:
The solution code is written in Java.
Firstly, create a Scanner object to get user input (Line 7). Next we use nextDouble method from Scanner object to get user first and second floating-point number (Line 9-15).
Next, display R and T and result of their summation, difference and product (Line 18-28).