Welcome :Guest

 Sign In Register
Win Surprise Gifts!!!
Congratulations!!!

Top 5 Contributors of the Month
Sasi Prabhu
Python Training
Santosh
Sameera Manepalli
Ram

 Home >> Code Snippets >> OOPS >> Post New Resource

# Java program using user package to calculate circle and rect ,square formula.

Posted By:laptop charles       Posted Date: June 30, 2010    Points: 10    Category: OOPS    URL: http://www.dotnetspark.com

Graphical formula.

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:
{

}
}
}

}
}```

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
 Find More code samples in C#, ASP.Net, Vb.Net and more Here