Question: I'm taking Intro to Java Programming need help finding what's wrong with this problem. Any help will be greatly appreciated. What is wrong with this

I'm taking Intro to Java Programming need help finding what's wrong with this problem. Any help will be greatly appreciated.

What is wrong with this code? Provide the line numbers and fix(es) if any. Please Note: Consider the variable declaration lines 6 & 7 to be correct as they are presented.

1.

2. //Instantiate a new Scanner object

3. Scanner sc = new Scanner(System.in);

4.

5. //Declarations

6. double rad1; //radius 1 - used for circle and ellipse

7. double rad2; //radius 2 - used for the ellipse w/rad1

8.

9. System.out.print("Enter radius one: ");

10. rad1 = sc.nextInt();

11. System.out.print("Enter radius two: ");

12. rad2 = sc.nextDouble();

13.

14. System.out.printf("The area of a circle with a radius of %.2f "

15. + "equals %.4f ", rad1, circularArea(rad1));

16. System.out.printf("The area of an ellipse with a radius of %.2f "

17. + "and %.2f equals %.4f ", r1, r2, circularArea(rad1, rad2));

18.

19. } //End Main Method

20.

21. /*Method: circularArea()

22. *@ params: r1

23. */

24. private static double circularArea(int r1) {

25. return Math.PI * Math.pow(r1, 2);

26. }//End circularArea method

27.

28. /*Method: circularArea() - overloaded

29. *@ params: r1, r2

30. */

31. private static double circularArea(double r1, double r2, String color) {

32. return Math.PI * r1 * r2;

33. }//End overloaded circularArea method Previous Next

34.

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 Databases Questions!