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

This is a JAVA question This is a main class & method These are the two sub clas

ID: 3858754 • Letter: T

Question

This is a JAVA question

This is a main class & method

These are the two sub classes

Main Class: 4 errors

SuperClass Circle: 3 errors

SubClass Oval: 2 errors

What are they and how can they be fixed?

//Begin Class Midweek Week1 12 public class Midweek Weekii 13 14 15 //Begin Main Method public static void main (Stringt args) 17 18 19 20 21 /Instantiate instances of subclasses Circle cinew CircleO: oval oval new Cir(); //set value f r circle cir.setRadi (21.5) ; 23 24 25 26 27 28 29 30 31 32 //Output data called from subclasse System.out.printin ("Cizcle Characteristics") System.out.printf ("Radius: System.out.printf ("Azea: % .2 f ", cir·setRadl ( ) ) ; 2f ", cir. calculateArea ( ) ) ; //Set value f r oval oval.setRad2 (11.32): //Output data called from 3ubc1a3es System.out.println(noval ChazacteristICS System.out.printf ("Radius 1 System.out.printf ("Radius 2 System.out.printf ("Oval Area:.21m", oval.calculateArea (0): %.2E ", oval.getAad1()); 22 n",cir.getRad2 O) 34 35 36 37 38 39 40 } //End Cla 3Midweekweek11 41 //End Main Method

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