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

The following class Plot has incomplete codes. Complete the missing lines of cod

ID: 3846264 • Letter: T

Question

The following class Plot has incomplete codes. Complete the missing lines of codes for the given (two) parameterized constructors, calculatePercentUtilised() method and toString()method. Hint: percentUtilised value can be calculated, by using the following formula, and returned by the method c a l c u l a t e P e r c e n t U t i l i s e d (). percentUtilised = (builtUpArea / plotArea) * 100

public class Plot

{

private double plotArea;

private double builtUpArea;

public Plot ( double givenPlotArea)

{ //Missing lines of code have to be completed }

public Plot ( double givenPlotArea, double givenBuiltUpArea)

{ //Missing lines of code have to be completed }

public double calculatePercentUtilised()

{ //Missing lines of code have to be completed }

@Override public String toString()

{ //Missing lines of code have to be completed }

}//end class definition

Explanation / Answer

Below is your code. I have added a driver class also to demonstrate that it works.

Plot.java


public class Plot {
   private double plotArea;
   private double builtUpArea;

   public Plot(double givenPlotArea) {
       this.plotArea = givenPlotArea;
   }

   public Plot(double givenPlotArea, double givenBuiltUpArea) {
       this.plotArea = givenPlotArea;
       this.builtUpArea = givenBuiltUpArea;

   }

   public double calculatePercentUtilised() {
       double percentUtilised = (builtUpArea / plotArea) * 100;
       return percentUtilised;
   }

   @Override
   public String toString() {
       return "Plot Area: " + this.plotArea + ", BuiltUp Area" + this.builtUpArea + " Percent Utilized: "
               + calculatePercentUtilised() + "%";
   }
}// end class definition

PlotDriver.java


public class PlotDriver {
   public static void main(String[] args) {
       Plot aPlot = new Plot(30.45,25);
       Plot bPlot = new Plot(68,50);
       System.out.println(aPlot);
       System.out.println(bPlot);
   }
}

Sample Run: -

Plot Area: 30.45, BuiltUp Area25.0 Percent Utilized: 82.10180623973727%
Plot Area: 68.0, BuiltUp Area50.0 Percent Utilized: 73.52941176470588%

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