Computer Applications
Write a program to print:
i. p to the power q
ii. the square root of p
The values of p and q are 64 and 2 respectively.
Java
Java Math Lib Methods
54 Likes
Answer
public class KboatNumber
{
public static void main(String args[]) {
int p = 64;
int q = 2;
double r1 = Math.pow(p, q);
System.out.println("p to the power of q = " + r1);
double r2 = Math.sqrt(p);
System.out.println("Square root of p = " + r2);
}
}
Output
Answered By
26 Likes
Related Questions
Write a program to generate random integers in the range 10 to 20.
Write valid statements for the following in Java:
i. Print the rounded off value of 234.49
ii. Print the absolute value of -9.99
iii. Print the largest of -45 and -50
iv. Print the smallest of -56 and -57.4
v. Print a random integer between 50 and 70
vi. Print 10.5 raised to the power 3.8
Write the equivalent Java statements for the following, only using the mathematical functions:
i. Print the positive value of -101.
ii. Store the value -125 in a variable and print its cube root.
iii. Store the value 89.99 in a variable and convert it into its closest integer that is greater than or equal to 89.99.
Write a program in Java to find the minimum of three numbers using Math.min() method.