Welcome :Guest

Congratulations!!!

Top 5 Contributors of the Month
momu198
Imran Ghani
Sohaib Khalid

 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
{
{
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("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");

switch(sn)
{
case 1:
{
double r,area;
area=3.14*r*r;
c.put("The area of circle"+area);
break;

}
case 2:
{
double b,h,area;
c.put("Enter the breath");
c.put("Enter the height");
area=0.5*b*h;
c.put("The area of circle"+area);
break;
}

case 3:
{
double r,h,area;
c.put("Enter the height");
area=3.14*r*r*h;
c.put("The area of cylinder"+area);
break;
}

case 4:
{
int si,area;
c.put("Enter the side");
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