Define a Java class LinearMeasure that represents linear measurements in either yards, feet, inches, meters, centimeters, or millimeters. The class should implement the interface Comparable and...


Define a Java class LinearMeasure that represents linear measurements in either yards, feet, inches, meters, centimeters, or millimeters. The class should implement the interface Comparable and override the method toString.


Use an enumeration to represent these units of measure. Note that a measurement is given and represented in only one of these units. For example, 8.5 yards is not represented as 8 yards, 1 foot, and 6 inches. Define a constructor that has two parameters, one that represents the value of the measurement and another that names the unit of measure as a string. The case of the letters in this string should be irrelevant. Define methods that convert any measurement to any given unit. These methods should not change the receiving object, but rather should return a new LinearMeasure object. For example, the statements


LinearMeasure length = new LinearMeasure(8.5, "yards");


System.out.println(length + " = " + length.toMeters());


should produce the following output:


8.5 yards = 7.7724 METERS


Write a client that fully demonstrates your class.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here