0% found this document useful (0 votes)
7 views11 pages

Square Root of 10.24 Explained

Uploaded by

89wov2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Square Root of 10.24 Explained

Uploaded by

89wov2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 6

Mathematical Library Methods


[Link] the correct

[Link] of the following is false to find square of a number?


[Link](a,2)
[Link] type of value is returned by [Link]( )?
Double
[Link] of the following syntax is true to find the square root of a number?
[Link](a)
[Link] the class that is used for different Mathematical functions.
[Link]
[Link] the output of the [Link](x); when x = -9.99
9.99
[Link] the output of [Link](x); when x = 9.0
3.0
[Link] the output

[Link]([Link](10.24));

Output

3.2

Explanation

[Link] method gives the square root of a positive number. Square root of 10.24 is
3.2 so it is the output.

[Link]([Link](-99.4));

Output

-99.0

Explanation

[Link] method rounds off its argument to the nearest mathematical integer and
returns its value as a double type. The nearest integer to -99.4 is -99.0 so that is the
output. [Link] method behaves in a particular way at the mid-point i.e. when the
decimal part of the argument is 0.5. In such cases, the result is the integer value that is
even. Let's understand this with an example. [Link](1.5) and [Link](2.5) will
both return 2.0. In the case of 1.5, both 1.0 and 2.0 are equally close to 1.5. [Link]
choses the integer that is even so 2.0 is returned. In the case of 2.5, both 2.0 and 3.0 are
equally close to 2.5. [Link] again choses the integer that is even so 2.0 is returned.

[Link]([Link](42.875));

Output

3.5
Explanation
[Link] method returns the cube root of its argument as a double value. Cube root of
42.875 is 3.5 so it is the output.

[Link]([Link](-25.5, -12.5));

Output

-25.5
Explanation
[Link] method returns the smaller of its 2 arguments. As -25.5 is smaller than -12.5
so it is the output.

[Link]([Link](-0.95));

Output

-0.0
Explanation
[Link] method returns the smallest double value that is greater than or equal to the
argument and is equal to a mathematical integer. If the argument value is less than zero
but greater than -1.0, then the result is negative zero which is the case in this .

[Link]([Link](-18.51));

Output -19

Explanation

[Link] method rounds off its argument to the nearest mathematical integer and
returns its value as an int or long type. At the mid-point i.e. when the decimal part of
the argument is 0.5, [Link] method rounds up to the higher integer. In this case,
the nearest integer to -18.51 is -19 so it is the output.
[Link]([Link](-77.66, -87.45));

Output

-77.66
Explanation
[Link] method returns the greater of its 2 arguments. As -77.66 is greater than
-87.45 so it is the output.

[Link]([Link](-0.88));

Output

-1.0
Explanation
[Link] method returns the largest double value that is less than or equal to the
argument and is equal to a mathematical integer. As -1.0 is the largest mathematical
integer less than -0.88 so it is the output.

[Link]([Link](98.5));

Output

98.0
Explanation
[Link] method rounds off its argument to the nearest mathematical integer and
returns its value as a double type. This method behaves in a particular way at the
mid-point i.e. when the decimal part of the argument is 0.5. In such cases, the result is
the integer value that is even. Let's understand this with an example. [Link](97.5)
and [Link](98.5) will both return 98.0. In the case of 97.5, both 97.0 and 98.0 are
equally close to 97.5. [Link] choses the integer that is even so 98.0 is returned. In
the case of 98.5, both 98.0 and 99.0 are equally close to 98.5. [Link] again choses
the integer that is even so 98.0 is returned.

[Link]([Link](65.5));

Output

66.0

[Link] down the syntax for the following functions


[Link] find the smaller between two numbers p and q
[Link](p, q)
[Link] find the absolute value of a number m

[Link](m)

[Link] find the exponent of a number k

[Link](k)

[Link] find the square root of a number d

[Link](d)

[Link] find the rounded-off of a number b

[Link](b)

[Link] the return data type of the following functions

[Link]( );

double

[Link]( );

double

[Link]( );

double

[Link]( );

int or long

[Link]( );

double

[Link]( )

double

[Link] the following functions

[Link]( )
Returns a positive double value, greater than or equal to 0.0 and less than 1.0.

[Link]( )

Returns the greater of its 2 arguments. Its return type is same as the type of its arguments.

[Link]( )

Returns the cube root of its argument as a double value.

[Link]( )

Returns the absolute value of its argument. Its return type is same as the type of its
arguments.

[Link]( )

Returns the natural logarithm of its argument. Both return type and argument is of
double data type.

VI. Distinguish between them with suitable examples

[Link]( ) and [Link]( )

[Link]( ) [Link]( )

Returns the smallest double value that Returns the largest double value that
is greater than or equal to the is less than or equal to the argument
argument and is equal to a and is equal to a mathematical
mathematical integer integer.

double a = [Link](65.5); double b = [Link](65.5);

In this example, a will be assigned the In this example, b will be assigned


value of 66.0 as it is the smallest the value of 65.0 as it is the largest
integer greater than 65.5. integer smaller than 65.5.
[Link]( ) and [Link]( )

[Link]( ) [Link]( )

Rounds off its argument to Rounds off its argument to the nearest
the nearest mathematical mathematical integer and returns its value as
integer and returns its value an int or long type. If argument is float, return
as a double type. type is int, if argument is double, return type is
long.

At mid-point, it returns the At mid-point, it returns the higher integer.


integer that is even

double a = [Link](1.5); long a = [Link](1.5);

double b =[Link](2.5); long b = [Link](2.5);

Both, a and b will have a a will have a value of 2 and b will have a value
value of 2.0 of 3

[Link] to Unsolved Java Programs

[Link] a program in Java to input three numbers and display the greatest and the
smallest of the two numbers.
Hint: Use [Link]( ) and [Link]( )
Sample Input: 87, 65, 34
Sample Output: Greatest Number 87
Smallest number 34

import [Link];
public class GreatestNumber
{
public static void main(String args[])
{
Scanner in = new Scanner([Link]);
[Link]("Enter First Number: ");
int a = [Link]();
[Link]("Enter Second Number: ");
int b = [Link]();
[Link]("Enter Third Number: ");
int c = [Link]();
int g = [Link](a, b);
g = [Link](g, c);
int s = [Link](a, b);
s = [Link](s, c);
[Link]("Greatest Number = " + g);
[Link]("Smallest Number = " + s);
}
}

Output

Enter First Number: 85

Enter Second Number: 96

Enter Third Number: 23

Greatest Number = 96

Smallest Number = 23

[Link] a program in Java to calculate and display the hypotenuse of a


Right-Angled Triangle by taking perpendicular and base as inputs.
Hint: h = √p2 + b2

import [Link];

public class Hypotenuse

public static void main(String args[])

Scanner in = new Scanner([Link]);

[Link]("Enter Perpendicular: ");

double p = [Link]();

[Link]("Enter Base: ");

double b = [Link]();

double h = [Link]([Link](p, 2) + [Link](b, 2));

[Link]("Hypotenuse = " + h);


}

OUTPUT

Enter Perpendicular: 5

Enter Base: 8

Hypotenuse = 9.433981132056603

[Link] a program to input a number and evaluate the results based on the
number entered by the user:
(a) Natural logarithm of the number
(b) Absolute value of the number
(c) Square root of the number
(d) Cube of the number
(e) Random numbers between 0 (zero) and 1 (one).

import [Link];

public class MathMethods

public static void main(String args[]) {

Scanner in = new Scanner([Link]);

[Link]("Enter Number: ");

double n = [Link]();

[Link]("Natural logarithm = " + [Link](n));

[Link]("Absolute value = " + [Link](n));

[Link]("Square root = " + [Link](n));

[Link]("Cube root= " + [Link](n));

[Link]("Random number = " + [Link]());

}
Output

Enter Number: 6
Natural logarithm = 1.791759469228055
Absolute value = 6.0
Square root = 2.449489742783178
Cube root= 1.8171205928321397
Random number = 0.890818613874519

[Link] an examination, you have appeared for three subjects i.e. Physics, Chemistry
and Biology. Write a program in Java to calculate the average mark obtained and
finally display the marks in rounded-off form.
Take Physics, Chemistry. and Biology marks as inputs.

import [Link];
public class AvgMarks
{
public static void main(String args[]) {
Scanner in = new Scanner([Link]);
[Link]("Enter Marks");
[Link]("Physics: ");
int p = [Link]();
[Link]("Chemistry: ");
int c = [Link]();
[Link]("Biology: ");
int b = [Link]();
double avg = (p + c + b) / 3.0;
long roundAvg = [Link](avg);
[Link]("Rounded Off Avg Marks = " + roundAvg);
}
}

Output

Enter Marks
Physics: 96
Chemistry: 80
Biology: 90
Rounded Off Avg Marks = 89
[Link] want to calculate the radius of a circle by using the formula:
Area = (22/7) * r2; where r = radius of a circle
Hence the radius can be calculated as:
r = √((7 * area) / 22)
Write a program in Java to calculate and display the radius of a circle by taking
area as an input.

import [Link];
public class KboatCircleRadius
{
public static void main(String args[]) {
Scanner in = new Scanner([Link]);
[Link]("Enter Area of Circle: ");
double area = [Link]();
double r = [Link](7 * area / 22);
[Link]("Radius of Circle = " + r);
}
}

Output

Enter Area of Circle: 56


Radius of Circle = 4.221158824088691

You might also like