Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dear professor Can you fix my code please! 1 //LandTractDemo Class 2 import java.util.Scanner; 3 public class LandTractDemo 4 { 5 private static double landLength;

Dear professor

Can you fix my code please!

image text in transcribed

image text in transcribed

1 //LandTractDemo Class 2 import java.util.Scanner; 3 public class LandTractDemo 4 { 5 private static double landLength; 6 //start main method 7 public static void main(String[]args) 8 { 9 //variables declaration 10 double landLength1, landLength2; 11 double landWidth1, landWidth2; 12 boolean equality; 13 //create an object for Scanner Class 14 Scanner input= new Scanner(System.in); 15 //Prompt the user for the length of the landLength 16 System.out.print("Enter the length of the land tract:"); 17 landLength1 = input.nextDouble(); 18 //prompt the user for the width of the land 19 System.out.print("Enter the width of the land tract:"); 20 landWidth1= input.nextDouble(); 21 //create an object for landTract Class 22 LandTract landTrack1= new LandTract(landLength1, landWidth1); 23 //prompt the user for the length of another land 24 System.out.print("Enter the length of another land tract:"); 25 landLength2= input.nextDouble(); 26 //prompt the user for the width of another land 27 System.out.print("Enter the width of another land tract:"); 28 landWidth2= input.nextDouble(); 29 //create another object for LandTract Class 30 LandTract landTrack2= new LandTract(landLength2, landWidth2); 31 Display the length, the width, and the area of the first land tract. 32 /* display the length and the width of the first land tract */ 33 System.out.println(" The Length and the width of the first land tract: "+ landTrack1.toString()); 34 //display the area of the first land Tract 35 System.out.println("The area of the first land tract:"+ landTrack1.getlandTractArea()); 36 Display the length, the width, and the area of the second land tract. 37 /* display the length and the width of the second land tract */ 38 return result; 39 }// end of toString method 40 41 }//end of LandTract class 42

1 LandTract.java 2 //LandTracr class 3 class LandTract 4 { 5 //variables declaration 6 private double tractLength; 7 private double tractWidth; 8 //default constructor 9 public LandTract() 10 { 11 tractLength=0; 12 tractWidth=0; 13 }//end of default constructor 14 //parameterized constructor 15 public LandTract(double newLength, double newWidth) 16 { 17 tractLength= newLength; 18 tractWidth= newWidth; 19 }//end of parameterized constructor 20 The following getLandTractArea method calculates and returns the area of the land tract. 21 //get getLandTractArea method implementation 22 public double getLandTractArea() 23 { 24 //local variables 25 double landTractArea; 26 //calculate the area of the land tract 27 landTractArea= tractLength * tractWidth; 28 //return the area of the land tract 29 return landTractArea; 30 } //end of getLandTractArea method 31 //equals method implementation 32 public boolean equals(LandTract otherLandTract) 33 { 34 //local variables 35 boolean isEqual; 36 /* compare the length and the width of both the current and the other land tracts*/ 37 if(tractLength != otherLandTract.tractLength|| tractWidth!= otherLandTract.tractWidth) 38 isEqual= false; 39 else 40 isEqual= true; 41 //returns the equality of the both objects 42 return isEqual; 43 //returns the equality of the both objects 44 return isEqual; 45 }// end of equals method 46 //toString method implementation 47 public String toString() 48 { 49 //create result as String 50 String result=""; 51 result +="Length:"+ tractLength; 52 result +="and Width:" + tractWidth; 53 }//end of toString method 54 }//end of landTract class

RoomCarpet - size : RoomDimension - carpetCost: double + RoomCarpet(dim RoomDimension, cost : double) + getTotalCost() : double + toString( String RoomDimension length : double width : double + RoomDimension(len : double, w double): + getArea0 : double + toString( String

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 SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago