Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a double), and one for the width (a double). The class should have:    a constructor that accepts arguments for the two fields    a method that returns the tract’s area(i.e. length * width)    an equals method that accepts a LandTract object as an argument. If the argument object   holds the same data (i.e. length and width) as the calling object, this method should return   true. Otherwise, it should return false.    a toString method (that returns a String representation of the tract’s length, width, and   area).   Demonstrate the class in a program by creating an array of three LandTract objects initialized with user input. Then, print the info of the LandTract objects stored in the array by invoking the toString method (implicitly or explicity). Also, use the equals method to compare at least two LandTract objects and print wether they are of equal size or not.   Sample Output:   Enter the length of Tract 1: 2   Enter the length of Tract 1: 3   Enter the length of Tract 2: 2   Enter the length of Tract 2: 3   Enter the length of Tract 3: 4   Enter the length of Tract 3: 5   Info of LandTract 1:   Length = 2.0   Width = 3.0   Area = 6.0   Info of LandTract 2:   Length = 2.0   Width = 3.0   Area = 6.0   Info of LandTract 3:   Length = 4.0   Width = 5.0   Area = 20.0   The first and second tracts are the same size.   Use Java

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
100%

Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a double), and one for the width (a double). The class should have:

 

 a constructor that accepts arguments for the two fields

 

 a method that returns the tract’s area(i.e. length * width)

 

 an equals method that accepts a LandTract object as an argument. If the argument object

 

holds the same data (i.e. length and width) as the calling object, this method should return

 

true. Otherwise, it should return false.

 

 a toString method (that returns a String representation of the tract’s length, width, and

 

area).

 

Demonstrate the class in a program by creating an array of three LandTract objects initialized with user input. Then, print the info of the LandTract objects stored in the array by invoking the toString method (implicitly or explicity). Also, use the equals method to compare at least two LandTract objects and print wether they are of equal size or not.

 

Sample Output:

 

Enter the length of Tract 1: 2

 

Enter the length of Tract 1: 3

 

Enter the length of Tract 2: 2

 

Enter the length of Tract 2: 3

 

Enter the length of Tract 3: 4

 

Enter the length of Tract 3: 5

 

Info of LandTract 1:

 

Length = 2.0

 

Width = 3.0

 

Area = 6.0

 

Info of LandTract 2:

 

Length = 2.0

 

Width = 3.0

 

Area = 6.0

 

Info of LandTract 3:

 

Length = 4.0

 

Width = 5.0

 

Area = 20.0

 

The first and second tracts are the same size.

 

Use Java 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,