Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a small program based on the following (Calculate area of a circle and th

ID: 3787075 • Letter: C

Question

Create a small program based on the following (Calculate area of a circle and the area of a rectangle):
//use an integer for the radius, sLength, sWidth, and areaRect
// use type double for the areaCir

1. Declare variables: radius, sideLength, sideWidth, areaRect, and areaCir.

2. Prompt for the radius of the circle.

3. Get the radius from the keyboard.

4. Calculate the area of the circle (use 3.14).

5. Display the radius and area of the circle onto the screen.

6. Prompt for the length of a side

7. Get the length from the keyboard

8. Prompt for the width of a side

9. Get the width from the keyboard .

10. Calculate the area of the rectangle

11. Display the side length, width, and area of the rectangle onto the screen.

can you also indicate each step (for instance: //declaring variables, //prompt user for radius of the circle etc.) so I can see how each one is done for future reference

Explanation / Answer

interface shape

{

double area;

void display ();

double pi=3.14;

}

class circle implements shape

{

private double r;

circle(double radius)

{

r=radius;

}

public void set(double radius)

{

r=radius;

}

public double area()

{

return pi*r*r;

}

public void display()

{

system.out.println("Area(circle):"+area());

}

class Rectangle implements shape

{

private double l,w;

Rectangle(double length double width)

{

l=length;

w=width;

}

public void set(double length,double width)

{

l=length;

w=width;

}

public double area()

{

return l*b;

}

system.out.println("Area:"+area());

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote