Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

=+What is the most that you should pay to complete development?

Answered: 1 week ago

Question

=+development and make the product, should you go ahead and do so?

Answered: 1 week ago