Some mathematical operation examples in Java


Here is the simple program for printing some mathematical operation example in Java.

Source Code

import java.io.*;
import java.util.Scanner;
import java.lang.Math;
//Tutor Joes Computer Education www.tutorjoes.com
class maths
{
  public static void main(String args[])
  {
    double a=2.2;
    double b;
    b=Math.sqrt(a);
    System.out.println("Square Root : "+b);
    b=Math.pow(4,2);
    System.out.println("Power : "+b);
    b=Math.sin(2);
    System.out.println("Sin : "+b);
    b=Math.cos(2);
    System.out.println("COS : "+b);
    b=Math.tan(2);
    System.out.println("Tan : "+b);
    b=Math.log(2);
    System.out.println("Log : "+b);
    b=Math.ceil(2.2);
    System.out.println("Ceil : "+b);
    b=Math.floor(2.58);
    System.out.println("Floor : "+b);
    b=Math.round(2.40);
    System.out.println("Round : "+b);
    b=Math.max(25,458);
    System.out.println("Max : "+b);
    b=Math.min(25,458);
    System.out.println("Min : "+b);
  }
}
To download raw file Click Here

Output

Square Root : 1.4832396974191326
Power : 16.0
Sin : 0.9092974268256817
COS : -0.4161468365471424
Tan : -2.185039863261519
Log : 0.6931471805599453
Ceil : 3.0
Floor : 2.0
Round : 2.0
Max : 458.0
Min : 25.0



Learn All in Tamil © Designed & Developed By Tutor Joes