Page 476 - CA_Blue( J )_Class10
P. 476
24 System.out.println("Piglatin Format : "+wordpig); // Printing of
Piglatin Format
25 }//close of main()
26 } //close of class
Output
Enter a word : Print
Piglatin Format : INTPRAY
Variable Description
NAME DATATYPE DESCRIPTION
word String Accept word to be converted
wordpig String Piglatin format of the word
ch char Character extracted from word
i int Loop Variable
len int Length of the sentence
j int Position of the first vowel in the word
PROGRAMS ON LIBRARY CLASSES
(a) Programs to demonstrate the use of Math class functions.
Program 16 Write a program to demonstrate the use of various mathematical functions provided by the Java
Math class, such as min(), max(), sqrt(), cbrt(), pow(), ceil(), floor(), exp(), abs(), log(), round(),
rint(), and random().
1 class mathematicalfunction // Declaration of class
2 {
3 public static void main()
4 {
5 // Different mathematical functions
6 System.out.println(" --Mathematical Functions --");
// Different mathematical functions
7 System.out.println("Math.min(3.4,5.8) : " + Math.min(3.4,5.8));
8 System.out.println("Math.max(3.4,5.8) : " + Math.max(3.4,5.8));
9 System.out.println("Math.sqrt(4.0) : " + Math.sqrt(4.0));
10 System.out.println("Math.cbrt(-27.0) : " + Math.cbrt(-27.0));
10 System.out.println("Math.pow(3,2) : " + Math.pow(3,2));
11 System.out.println("Math.ceil(3.4) : " + Math.ceil(3.4));
12 System.out.println("Math.floor(-5.8) : " + Math.floor(-5.8));
13 System.out.println("Math.exp(2) : " + Math.exp(2));
474474 Touchpad Computer Applications-X

