Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Area Class Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: - circles - rectangles

1. Area Class Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: - circles - rectangles - cylinders Here are the formulas for calculating the area of the shapes. Area of a circle: Area = r2 where p is Math.PI and r is the circle's radius Area of a rectangle: Area = Width x Length Area of a cylinder: Area = r2 h where p is Math.PI, r is the radius of the cylinder's base, and h is the cylinder's height Because the three methods are to be overloaded, they should each have the same name, but different parameter lists. Demonstrate the class in a complete program.

image text in transcribed

This is what I have so far

public class area {

public static double Area (double rad){

return Math.PI*rad*rad;

}

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

return length*width;

}

public static double Area (double radi,double height){

return Math.PI*rad*rad*height;

}

}

import java.util.Scanner;

public class main{

public static void main(String args[]){

Scanner input = new Scanner();

System.out.println("Enterradiustocalculatecirclearea:");

double rad = input.nextDouble();

System.out.println("Enterwidthtocalculaterectanglearea:");

double width = input.nextDouble();

System.out.println("Enterlengthtocalculaterectanglearea:");

double length = input.nextDouble();

System.out.println("Enterbaseradiustocalculatecylinderarea:");

double radi = input.nextDouble();

System.out.println("Enterheighttocalculatecylinderarea:");

double height = input.nextDouble();

System.out.println("Theareaofthecircleis:"+ area.Area(double radi);

System.out.println("Theareaoftherectangleis:"+ area.Area(double length,double width);

System.out.println("Theareaofthecylinderis:"+ area.Area(double radi,double height);

}

}

This is the error I am getting

image text in transcribed

SAMPLE RUN #3: java Area Interactive Session Hide Invisibles Highlight: None Highlight None *Show Highlighted Only ===-Area. Calculator. === Enter.radius.to calculate.circle.area:2.0 Enter width.to calculate.rectangle.area:3.5 . Enter . length-to-calculate . rectangle . area : 40- Enter.base.radius.to.calculate.cylinder area:8.0+ Enter-height . to . calculate-cylinder area: 5 . 7 Results:+ The area of the circle.is: 12.57+ The area of.the rectangle.is: 14.00 The area-of-the-cylinder-is:.1146.05

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

What is the logic behind debting one aspect and crediting another?

Answered: 1 week ago

Question

Which celebrity would you choose as a mentor?

Answered: 1 week ago

Question

Address it to art bowers, chief of production.

Answered: 1 week ago

Question

Dr. paul hansen is joining our staff.

Answered: 1 week ago

Question

When jones becomes ceo next month, well need your input asap.

Answered: 1 week ago