Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please compile code in Java and advise if we need 2 separate Java files for this. 1) -Write a main method to test the following

image text in transcribed

image text in transcribed

Please compile code in Java and advise if we need 2 separate Java files for this.

1) -Write a main method to test the following three methods. A) This getArea method returns the area of a rectangle public static double getArea(int length, int width) return length * width; 1 B) This getAreaCir method returns the area of a circle. public static double getAreacir (double radius) return Math.PI * radius * radius; 1 c) This getArea method returns the area of a cylinder. public static double getAreacyl (double radius, double height) return Math.PI * radius * radius * height; 1 2) Overload the above three methods and call those form main. Please watch the video on assign3.1 first to understand the overload concept. 1.e; in main method you should renames getAreacir->get, getArea->get And getAreaCyl=>get to justify overload instruction. More hint- package overloading; public class OverLoading public static void main(String[] args) { System.out.println("The getArea of a lenth 2 & width 4 is :" +get(4,2)); System.out.println("The area of a circle with raduis 4 is :" +get(4)); System.out.println("The area of a cylinder with raduis 4.0 & hight 2.0 :" +get(4.0,2.0)); 1 public static double get(int length, int width) 7...3 lines public static double get (double radius, double height) 1...3 lines) public static double get (double radius) 1...3 lines }

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

Step: 3

blur-text-image

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago