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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 11RQ
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT