Question
Write code in java. Create a class that will be used to hold measurement in feet, inches, yards, meters and centimeters. Use constant fields for
Write code in java.
Create a class that will be used to hold measurement in feet, inches, yards, meters and centimeters.
Use constant fields for the conversions. These constants can be assigned value when the fields are declares, since they are non-changing every time an instance is created. Write two constructor methods: the no-args which set the fields to zero and a second constructor that does take arguments.
Write five set( ) methods and five get( ) methods, one for each field.
Write a toString( ) method.
Create a second class named Driver. This class will have only one method And no fields. The only method in this Driver class is main( ).
In main( ) create an instance of your measurement class using the no-args constructor. Then in a loop provide the user a chance to set whichever field they chose. Make this looks good to the user, a menu would be best. Every Change the user enters requires a call to a set( ) method. Be sure your set( ) methods ensure ALL the fields are consistent. For each iteration of the loop, call the toString( ) method in a print statement to print the state of the measurement object.
The loop should repeat as long as the user wants to continue.
Once the loop exits, print a good-bye message.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started