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

My Chegg experts I need a little help from my friends. It\'s another week and I

ID: 3858035 • Letter: M

Question

My Chegg experts I need a little help from my friends. It's another week and I have some new issue to figure out. Can someone give me a little help with the below problems. The book for the class is Introduction to Java Programming, Comprehensive Version Y. Daniel Liang & Prentice Hall 11th Edition / 2018. We are currently working in Chapter 11. This chapter covers the following:

Principles of Inheritance

Principles of Polymorphism

Binding & Casting

Protected & Final Designators

Consider the following Main Class and Method:

Main Class & Method

11. // Begin Class Midweek_Week11

12. public class Midweek_Week11 {

13.

14. // Begin Main Method

15. public static void main (String [ ] args) {

16.

17. //Instantiate instances of subclasses

18. Circle cir = new Circle ( );

19. Oval oval = new Cir ( );

20.

21. //Set value for circle

22. cir.setRad1 (21.5) ;

23.

24. //Output data called from subclasses

25. System.out.println (“Circle Characteristic”) ;

26. System.out.printf (“ Radius: %.2f ”, cir.setRad1 ( ) ) ;

27. System.out.println (“Area: %.2f ”, cir.calculateArea ( ) ) ;

28.

29. //Set values for oval

30. oval.setRad2 (11.32) ;

31.

32.

33. //Output data called from subclasses

34. System.out.println (“ Cube Characteristics”) ;

35. System.out.printf (“ Radius 1: %.2f ”, oval.getsetRad1 ( ) ) ;

36. System.out.println (“Radius 2: %.2f ”, cir.getRad2 ( ) ) ;

37. System.out.println (“Oval Area: %.2f ”, oval.calculateArea ( ) ) ;

38.

39. } //End Main Method

40.

41. //End Class Midweek_Week11

42.

As you can tell from the main class, two sub classes exist:

Super Class Circle

12. import static java.lang.Math.*;

13. //Begin Subclass Circle

@ public class Circle {

15. //Class wide variable

16.

17. private double rad1;

18. private double rad2;

19.

20. //Set radius 1 method

21. private void setRad1 (double r1) {

22. rad1 = r1;

23. }//End set side method

24.

25. //Get radius 1 method

26. public double getRad1( ) {

27. return rad1;

28. //End get side method

29.

30. //Set radius 1 method

31. private void setRad2 (double r2) {

32. rad2 = r2;

33. }//End set side method

34.

35. //Get radius 1 method

36. public double getRad2( ) {

37. return rad2;

38. //End get side method

39.

40. //Calculate area method

@ public double calculateArea ( ) {

42. return PI * poe(rad1, 2);

43. }

44. }//End Subclass Circle

45.

Sub Class Oval

11. import static java.lang.Math.*;

12. //Begin Subclass Oval

13. public class Oval {

14.

15. //**

16. *Method to determine area of an Oval

17. *@return

18. */

19. public double calculateArea ( ) {

20. return PI * (getRad1( ) * getRad2( ) );

21. }

22. } //End Subclass Oval

23.

24.

There are issues in all three class. Each contains the following:

   1.   Main Class: 4 errors

   2.   SuperClass Circle: 3 errors

   3.   SubClass Oval: 2 errors

Submit the line number, issue and all corrections.

Explanation / Answer

In Midweek_Week11 class, we have below errors.

Lines: 19, 27, 36, 37

In Circle class, we have below errors

Lines: 21, 31, 42

In Oval class, we have below errors

Lines: 13, 15

Midweek_Week11.java

public class Midweek_Week11 {

// Begin Main Method

public static void main (String [ ] args) {

//Instantiate instances of subclasses

Circle cir = new Circle ( );

Circle oval = new Oval ( );

//Set value for circle

cir.setRad1 (21.5) ;

//Output data called from subclasses

System.out.println ("Circle Characteristic") ;

System.out.printf (" Radius: %.2f ", cir.getRad1 ( ) ) ;

System.out.printf ("Area: %.2f ", cir.calculateArea ( ) ) ;

//Set values for oval

oval.setRad2 (11.32) ;

//Output data called from subclasses

System.out.println (" Cube Characteristics") ;

System.out.printf (" Radius 1: %.2f ", oval.getRad1 ( ) ) ;

System.out.printf ("Radius 2: %.2f ", cir.getRad2 ( ) ) ;

System.out.printf ("Oval Area: %.2f ", oval.calculateArea ( ) ) ;

} //End Main Method

//End Class Midweek_Week11

}

Circle.java


import static java.lang.Math.*;
//Begin Subclass Circle
public class Circle {
//Class wide variable

private double rad1;
private double rad2;
//Set radius 1 method
public void setRad1 (double r1) {
rad1 = r1;
}//End set side method

//Get radius 1 method
public double getRad1( ) {
return rad1;
}
//End get side method

//Set radius 1 method
public void setRad2 (double r2) {
rad2 = r2;
}//End set side method

//Get radius 1 method
public double getRad2( ) {
return rad2;
}
//End get side method

//Calculate area method
public double calculateArea ( ) {
return PI * pow(rad1, 2);
}
}//End Subclass Circle

Oval.java


import static java.lang.Math.*;
//Begin Subclass Oval
public class Oval extends Circle{

/**
*Method to determine area of an Oval
*@return
*/
public double calculateArea ( ) {
return PI * (getRad1( ) * getRad2( ) );
}
} //End Subclass Oval

Output:

Circle Characteristic
Radius: 21.50
Area: 1452.20

Cube Characteristics
Radius 1: 0.00
Radius 2: 0.00
Oval Area: 0.00

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