[All Math library Programs From APC Class 9]
import java.util.Scanner;
class Q1{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter three numbers:");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int g = Math.max(a,Math.max(b,c)); //greatest
int s = Math.min(a,Math.min(b,c)); //smallest
System.out.println("The greatest is:"+g);
System.out.println("The smallest is:"+s);
}
}
import java.util.Scanner;
class Q2{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the perpendicular:");
int p = sc.nextInt();
System.out.println("Enter the breadth:");
int b = sc.nextInt();
double h = Math.sqrt(p*p+b*b);
System.out.println("The hypotenuse is:"+h);
}
}
import java.util.Scanner;
class Q3{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number:");
double n = sc.nextDouble();
System.out.println("Natural logarithm :"+Math.log(n));
System.out.println("Absolute value:"+Math.abs(n));
System.out.println("Square root:"+Math.sqrt(n));
System.out.println("Cube of the number:"+Math.pow(n,3));
System.out.println("Random numbers between 0 and 1:"+Math.random());
}
}
import java.util.Scanner;
class Q4{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter physics:");
double p = sc.nextDouble();
System.out.println("Enter biology:");
double b = sc.nextDouble();
System.out.println("Enter chemistry:");
double c = sc.nextDouble();
int avg = Math.round((p+b+c)/3);
System.out.println("Average marks:"+avg);
}
}
import java.util.Scanner;
class Q5{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the area of the circle:");
double area = sc.nextDouble();
double r = Math.sqrt((7*area)/22);
System.out.println("Radius of the circle:"+r);
}
}