Lec: 9 |JAVA

    

LEC:9

JAVA Math Class and their functions

   

 
    




Source Code:
package lec_5;
import java.util.*;
public class Lec_5 {
public static void main(String[] args) {
        
    int x=36,y=89;
    System.out.println(Math.max(x, y)); // to find the maximum number
    System.out.println(Math.min(x, y)); // to find the minimum number
    
    System.out.println(Math.sqrt(x));// to find the square root of any number
    int abc=-78;
    System.out.println("the value of abc "+ abc);
    // to find the Absolute value of any number
    System.out.println("the value of abc "+ Math.abs(abc));
    
//Generationg a random number

    //any random number in between 0 to 1
    //System.out.println("So generating a RANDOM NUMBER in the range of 0 to 1\t" + Math.random());
    //if want to generate a random number in between 0 to 100
     float random1=(float)Math.random()*101; 
    System.out.println("The random number is" + random1);
    
    }       

}

Comments

Popular posts from this blog

RunwayWithCode

web development Lectures

C++ Lectures