Question
Read the entire document before starting to write code. Write and test a Java project that satisfies the following requirements: Create a measurement converter project
Read the entire document before starting to write code. Write and test a Java project that satisfies the following requirements:
Create a measurement converter project that can convert between units of price. (pounds and ounces).
Use this table of conversion for your calculations.
The constant for conversion is 1 pound = 16 ounces or 16 ounces = 1 pound
Write a class definition file named UnitPriceConverter that has these fields and one constant.
priceOfItem weightInPounds pricePerPound pricePerOunce constant: ouncesPerPound
Write the following methods: Two constructor methods:
The default constructor sets all the field values to zero except the constant. The constant is set using the conversion given above.
The overloaded constructor accepts a value for the price of the item and the weight of the item in pounds and then calculates the values for pricePerPound and pricePerOunce (use the constant for your conversion calculation).
Write two set( ) methods that allows the user to change the price of the item and the weight in pounds. This set( ) method must recalculate the price per pound and the price per ounce.
Write four get( ) methods. Once to get the price, one to get the weight in pounds, one to get the price per pound and one to get the price per ounce.
Write a driver class with the main( ) method. This main method should provide the following utility:
Create an instance of the UnitPriceConverter using the default values.
Write a loop that allows the user to reset the price and/or weight in pounds using the set( ) method and prints both the price per pound of the item and the price per ounce of the item in each iteration. Continue looping until the user indicates he/she is done. After the user decides to quit, print a goodbye 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