Question: public static void main ( String [ ] args ) { System.out.println ( Thank you for using the area calculator ) ; System.out.println (
public static void mainString args
System.out.printlnThank you for using the area calculator";
System.out.printlnThis calculator lets you get the area of: ;
System.out.println Square
Rectangle
Triangle
Circle
;
Task Call area functions.
double square area of square with a side of
double rectangle area of rectangle with a length of and a width of
double triangle area of triangle with a base of and a width of
double circle area of circle with a radius of
Task Call a function that prints all the areas.
Task 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:
If the side is negative, prints "Error: impossible" and terminates the java program.
Calculates the area of the square. A side
public static double areaSquaredouble side
return ;
Task 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:
If the length OR width is negative, prints "Error: impossible" and terminates the program.
Calculates the area of the rectangle. A length width
public static double areaRectangledouble length, double width
return ;
Task 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:
If the base OR height is negative, prints "Error: impossible" and terminates the program.
Calculates the area of the triangle. A base height
public static double areaTriangledouble base, double height
return ;
Task 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:
If the radius is negative, prints "Error: impossible" and terminates the program.
Calculates the area of the circle.
public static double areaCircledouble radius
return ;
Task : 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:
print: Square area:
print: Rectangle area:
print: Triangle area:
print: Circle area:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
