In a file called ThreeOperations.java, write a program that: Asks the user to enter two real numbers (doubles, not integers) called N1 and N2. It is OK if your program crashes when the user does not enter valid double numbers. Computes and displays the following operations between the two: multiplication, division, exponentiation. For the results of these two operations, only two decimal digits should be displayed.
import java.util.Scanner; public class ThreeOperations { public static void main(String[] args) { double N1, N2; Scanner scanner = new Scanner(System.in); System.out.print("Enter two real numbers: "); N1 = scanner.nextDouble(); N2 = scanner.nextDouble(); System.out.println(N1*N2); System.out.println(N1/N2); System.out.println(Math.pow(N1,N2)); } }
Get Answers For Free
Most questions answered within 1 hours.