You are on page 1of 2

Solution for unsolved Programs of Chapter 6 (page - 145)

1.

import java.util.*;
class min_max1
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a, b, c, m, n, p, q;
System.out.println("Enter three numbers ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();

m = Math.min(a,b);
n = Math.min(c,m);

p = Math.max(a,b);
q = Math.max(c,p);

System.out.println("Smallest number = "+n);


System.out.println("Greatest number = "+q);
}
}
2.

import java.util.*;
class hyp2 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
double b, p,h;
System.out.println("Enter perpendicular and base ");
p = in.nextInt();
b = in.nextInt();

h = Math.sqrt(Math.pow(p,2)+Math.pow(b,2));

System.out.println("hyp = "+h);
}
}

3.
import java.util.*;
class math3 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n;
System.out.println("Enter a num ");
n = in.nextInt();

System.out.println("Absolute value = " + Math.abs(n));


System.out.println("Square root = " + Math.sqrt(n));
System.out.println("Cube= " + Math.pow(n,3));
System.out.println("Random number = " + Math.random());
}
}

4.
import java.util.*;
class avg4 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
double b,c, p,h;
System.out.println("Enter marks of phy,chem, bio ");
p = in.nextDouble();
c = in.nextDouble();
b = in.nextDouble();

double avg = (p+c+b)/3;

System.out.println("Average marks = "+ Math.round(avg));

}
}

5.
import java.util.*;
class rad5 {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
double ar,r;
System.out.println("Enter area of a circle ");
ar = in.nextDouble();

r = Math.sqrt((7*ar)/22);

System.out.println("Radius = "+r);
}
}

You might also like