Professional Documents
Culture Documents
Lab Manual 3rd Week
Lab Manual 3rd Week
Lab Manual 3rd Week
Objectives:
To determine the scope of variables.
To solve mathematical problems by using the methods in the Math class
Examples:
Example 01. Write Java program with the same method twice where it takes a single argument.
The program prints the value of x squared to the screen:
a. What is the difference between x and y variables in terms of scope ?
System.out.println(y*y);
return;
double x = 5.0;
printSquare(3.0);
printSquare(x);
Output :
9.0
25.0
Example02. Write Java program to call suitable functions from the Math class solve the
following mathematical questions:
Round a floating-point value up of 7.343 to the nearest integer value.
Find the value of 2 raised to the power of 8.
Find the logarithm of 1.
°
Find the cosine value of 45 in radians.
import java.lang.Math;
Output:
Logarithm of 1 is 0.0