Question: public static void main ( String [ ] args ) { System.out.println ( Thank you for using the area calculator ) ; System.out.println (

public static void main(String[] args){
System.out.println("Thank you for using the area calculator");
System.out.println("This calculator lets you get the area of: ");
System.out.println("1- Square
2- Rectangle
3- Triangle
4- Circle
");
//Task 5 Call area functions.
// double square = area of square with a side of 2.
// double rectangle = area of rectangle with a length of 1, and a width of 2.
// double triangle = area of triangle with a base of 1, and a width of 2.
// double circle = area of circle with a radius of 2.
//Task 7 Call a function that prints all the areas.
}
//Task 1- Write a function that calculates the area of a square.
/**
* Function name: areaSquare - returns the area of a square.
* @param side (double)
* @return the area (double)
*
* Inside the function:
*1. If the side is negative, prints "Error: impossible" and terminates the java program.
*2. Calculates the area of the square. A = side^2
*/
public static double areaSquare(double side){
return 0;
}
//Task 2- Write a function that calculates the area of a rectangle.
/**
* Function name: areaRectangle returns the area of a rectangle.
* @param length (double).
* @param width (double).
* @return the area (double)
*
* Inside the function:
*1. If the length OR width is negative, prints "Error: impossible" and terminates the program.
*2. Calculates the area of the rectangle. A = length * width
*/
public static double areaRectangle(double length, double width){
return 0;
}
//Task 3- Write a function that calculates the area of a triangle.
/**
* Function name: areaTriangle it returns the area of a triangle.
* @param base: (double).
* @param height: (double).
* @return the area (double)
*
* Inside the function:
*1. If the base OR height is negative, prints "Error: impossible" and terminates the program.
*2. Calculates the area of the triangle. A =(base * height)/2
*/
public static double areaTriangle(double base, double height){
return 0;
}
//Task 4- Write a function that calculates the area of circle.
/**
* Function name: areaCircle it returns the area of a circle.
* @param radius (double).
* @return area (double)
*
* Inside the function:
*1. If the radius is negative, prints "Error: impossible" and terminates the program.
*2. Calculates the area of the circle.
*/
public static double areaCircle(double radius){
return 0;
}
//Task 6: Write a function that prints every area.
/**
* Function name: printAreas it prints four areas
* @param square square area (double)
* @param rectangle rectangle area (double)
* @param triangle triangle area (double)
* @param circle circle area (double)
*
* Inside the function:
*1. print: ("Square area: ")
*2. print: ("Rectangle area: ")
*3. print: ("Triangle area: ")
*4. print: ("Circle area: ")
*
*/
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!