Chapter 6 Class X
Chapter 6 Class X
chapter – 6 calss x
State whether the following statements are 'True' or 'False'
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
System.out.println(Math.floor(-4.7));
Output
-5.0
Explanation
Math.floor method returns the largest double value that is less than or equal to the argument and
is equal to a mathematical integer. As -5.0 is the largest mathematical integer less than -4.7 so it
is the output. Note that -4.7 is a negative number so the largest integer less than -4.7 is -5.0
and not -4.0.
Question 2
System.out.println(Math.rint(-9.4)+Math.sqrt(9.0));
Output
-6.0
Explanation
Math.rint(-9.4) will give -9.0 as it is nearest integer to -9.4. Math.sqrt(9.0) will give 3.0. So,
output will be -9.0 + 3.0 = -6.0
Question 3
System.out.println(Math.max(Math.ceil(14.55),15.5));
Output
15.5
Explanation
Math.ceil(14.55) gives 15.0 as it is the smallest whole number greater than 14.55. After that
Math.Max() becomes Math.max(15.0, 15.5). As 15.5 is greater than 15.0, it is the output.
Question 4
System.out.println(Math.sqrt(Math.min(42.5,42.25)));
Output
6.5
Explanation
Question 5
System.out.println(Math.ceil(3.4)+Math.pow(2,3));
Output
12.0
Explanation
Math.ceil(3.4) gives 4.0 and Math.pow(2,3) gives 8.0. So the output is 4.0 + 8.0 = 12.0.
Math.log(q)
Question 2
Math.cbrt(m)
Question 3
Math.round(k)
Question 4
Math.abs(y)
Question 5
Math.exp(p)
Returns a positive double value, greater than or equal to 0.0 and less than 1.0.
Question 2
Math.pow()
Returns the value of the first argument raised to the power of the second argument. Data
type of the two arguments and the return type of this method is double.
Question 3
Math.cbrt()
Question 4
Math.log()
Returns the natural logarithm of its argument. Both return type and argument is of double
data type.
Distinguish between
Question 1
Math.ceil( ) Math.floor( )
Returns the smallest double value that is greater Returns the largest double value that is less than
than or equal to the argument and is equal to a or equal to the argument and is equal to a
mathematical integer mathematical integer.
double a = Math.ceil(65.5);
double b = Math.floor(65.5);
In this example, a will be assigned the value of
In this example, b will be assigned the value of
66.0 as it is the smallest integer greater than
65.0 as it is the largest integer smaller than 65.5.
65.5.
Question 2
Math.rint( ) Math.round( )
Rounds off its argument to the Rounds off its argument to the nearest mathematical integer
Math.rint( ) Math.round( )
and returns its value as an int or long type. If argument is
nearest mathematical integer and
float, return type is int, if argument is double, return type is
returns its value as a double type.
long.
At mid-point, it returns the integer
At mid-point, it returns the higher integer.
that is even
double a = Math.rint(1.5); long a = Math.round(1.5);
double b =Math.rint(2.5); long b = Math.round(2.5);
Both, a and b will have a value of 2.0 a will have a value of 2 and b will have a value of 3
import java.util.Scanner;
Output
Question 2
For every natural number m>1; 2m, m2-1 and m2+1 form a Pythagorean triplet. Write a program
to input the value of 'm' through console to display a 'Pythagorean Triplet'.
Sample Input: 3
Then 2m=6, m2-1=8 and m2+1=10
Thus 6, 8, 10 form a 'Pythagorean Triplet'.
import java.util.Scanner;
if (m < 2) {
System.out.println("Invalid Input, m should be greater than 1");
return;
}
int firstTriplet = 2 * m;
int secondTriplet = (int)(Math.pow(m, 2) - 1);
int thirdTriplet = (int)(Math.pow(m, 2) + 1);
}
}
Output
Question 3
Write a program to input a number. Calculate its square root and cube root. Finally, display the
result by rounding it off.
Sample Input: 5
Square root of 5= 2.2360679
Rounded form= 2
Cube root of 5 = 1.7099759
Rounded form= 2
import java.util.Scanner;
Output
Question 4
import java.util.Scanner;
Output
Question 5
import java.util.Scanner;
Output
Question 6
import java.util.Scanner;
public class KboatQuadEq
{
public static void main(String args[]) {
System.out.print("Enter a: ");
int a = in.nextInt();
System.out.print("Enter b: ");
int b = in.nextInt();
System.out.print("Enter c: ");
int c = in.nextInt();
Output