In: Computer Science
In a file called ThreeOperations.java, write a program that:
For example: if the user enters numbers 11 and 7, your program output should look EXACTLY like this:
Please enter real number N1: 11 Please enter real number N2: 7 11.000000 * 7.000000 = 77.00 11.000000 / 7.000000 = 1.57 11.000000 raised to the power of 7.000000 = 19487171.00
As another example: if the user enters numbers 3.25 and 10.3, your program output should look EXACTLY like this:
Please enter real number N1: 3.25 Please enter real number N2: 10.3 3.250000 * 10.300000 = 33.48 3.250000 / 10.300000 = 0.32 3.250000 raised to the power of 10.300000 = 187239.99
import java.util.Scanner;
public class TestOperations {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
// reading numbers
System.out.println("Please enter
real number N1: ");
double n1 = sc.nextDouble();
System.out.println("Please enter
real number N2: ");
double n2 = sc.nextDouble();
// printing product
System.out.printf("%f * %f = %f\n",
n1, n2, n1 * n2);
// printing division
System.out.printf("%f / %f = %f\n",
n1, n2, n1 / n2);
// printing power
System.out.printf("%f raised to the
power of %f = %f", n1, n2, Math.pow(n1, n2));
}
}
Note : If you like my answer please rate and help me it is very Imp for me