//Java program to Perform Volume
calculation Using method overloading
import java.util.Scanner;
class methods
{
double volume(int r,int h)
{
double s;
s=((4/3)*3.14*r*r*h);
return s;
}
int
volume(int a)
{
int r1;
r1=4*a;
return r1;
}
}
class volume
{
public static void main(String args[])
{
int r,h,a;
methods m=new methods();
Scanner sp=new Scanner(System.in);
System.out.println("\t VOLUME OF SPHERE\n");
System.out.println("\t ****** ** ******\n");
System.out.println("Enter
the sphere radious:");
r=sp.nextInt();
System.out.println("Enter the sphere height:");
h=sp.nextInt();
double c1;
c1=m.volume(r,h);
System.out.println("\t AREA OF SQUARE\n");
System.out.println("\t **** ** ******\n");
System.out.println("Enter the side of square:");
a=sp.nextInt();
int c2;
c2=m.volume(a);
System.out.println("volume of sphere="+c1);
System.out.println("volume of square="+c2);
}
}
No comments:
Post a Comment