Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

GeoJavaProgramChaP5

java 5

Uploaded by

jikitacwb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

GeoJavaProgramChaP5

java 5

Uploaded by

jikitacwb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

* menu of options

*/

public static void printMenu() {

System.out.println("Choose a shape to calculate:");

System.out.println("1. Circle Area");

System.out.println("2. Rectangle Area");

System.out.println("3. Triangle Area");

System.out.println("4. Circle Circumference");

System.out.println("5. Rectangle Perimeter");

System.out.println("6. Triangle Perimeter");

System.out.print("Enter your choice: ");

/**

* circle area.

* @param radius the radius of the circle

* @return the area of the circle

*/

public static double circleArea(double radius) {

return Math.PI * Math.pow(radius, 2);

/**

* rectangle.

* @param length the length of the rectangle

* @param width the width of the rectangle

* @return the area of the rectangle


*/

public static double rectangleArea(double length, double width) {

return length * width;

/**

* Calculates the area of a triangle.

* @param height the height of the triangle

* @param base the base of the triangle

* @return the area of the triangle

*/

public static double triangleArea(double height, double base) {

return 0.5 * base * height;

/**

* Calculates the circumference of a circle.

* @param radius the radius of the circle

* @return the circumference of the circle

*/

public static double circumference(double radius) {

return 2 * Math.PI * radius;

/**

* perimeter of a rectangle.

* @param length the length of the rectangle


* @param width the width of the rectangle

* @return the perimeter of the rectangle

*/

public static double rectanglePerimeter(double length, double width) {

return 2 * (length + width);

/**

* C perimeter triangle.

* @param side1 the length of the first side of the triangle

* @param side2 the length of the second side of the triangle

* @param side3 the length of the third side of the triangle

* @return the perimeter of the triangle

*/

public static double trianglePerimeter(double side1, double side2, double


side3) {

return side1 + side2 + side3;

You might also like