Using package to calculate the circle and rect ,square and spare formula.
The below coding inside the folder name is rand.
package rand;
import java.io.*;
public class chpackage
{
public String read()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
return str;
}
public void paste(String st)
{
System.out.print(st);
}
public void put(String pu)
{
System.out.println(pu);
}
}The below code is outside of the folder.
import rand.*;
import java.io.*;
class pk4
{
public static void main(String ar[])throws IOException
{
chpackage c=new chpackage();
c.put("AREA OF VARIOUS GEOMETRICAL FIGURES");
{
c.put("MAIN MENU");
c.put("1.Area of circle");
c.put("2.Area of triangle");
c.put("3.Area of cylinder");
c.put("4.Area of square");
c.put("5.Exit");
c.put("Enter your choice");
int sn=Integer.parseInt(c.read());
switch(sn)
{
case 1:
{
double r,area;
c.put("Enter the radius");
r=Double.parseDouble(c.read());
area=3.14*r*r;
c.put("The area of circle"+area);
break;
}
case 2:
{
double b,h,area;
c.put("Enter the breath");
b=Double.parseDouble(c.read());
c.put("Enter the height");
h=Double.parseDouble(c.read());
area=0.5*b*h;
c.put("The area of circle"+area);
break;
}
case 3:
{
double r,h,area;
c.put("Enter the radius");
r=Double.parseDouble(c.read());
c.put("Enter the height");
h=Double.parseDouble(c.read());
area=3.14*r*r*h;
c.put("The area of cylinder"+area);
break;
}
case 4:
{
int si,area;
c.put("Enter the side");
si=Integer.parseInt(c.read());
area=si*4;
c.put("The area of square"+area);
break;
}
case 5:
{
}
}
}
}
}