Create an instance of the weightconverter class

Assignment Help Programming Languages
Reference no: EM131321339

Test 1

You are permitted the use of pre-written notes, previous labs and the textbook. You are NOT permitted the help of the Lab TA or the Internet. Any cheating will result in a report Academic Integrity Violation and an ‘F' in the course.

Document your code with inline comments and javadoc comments. This is a majot portion of your grade.

Read this 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 grams, ounces, pounds and kilograms.

The constants for conversion are:

1 ounce = 28.35 grams
16 ounces = 1 pound
1 kg = 1000 grams

Write a class definition file named WeightConverter that has these fields:

weightInOunces
weightInPounds
weightInGrams
weightInKiloGrams

The class also needs the three constant fields for the conversions as listed above.

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 weight of an item in pounds and calculates the values for the remaining three fields.

Write four set( ) methods that allows the user to change any measure (setOunces, setPounds, setGrams, setKiloGrams) The set methods must ensure all the fields are consistent.

Write four get( ) methods. One get method for each of the four fields (not including the constants.

Write a driver class that has the main( ) method. This main method should provide the following utility:

Create an instance of the WeightConverter class using the default values.

Write a loop that allows the user to reset any of the measures. Ask the user to enter which measure to change, read in the value and call the appropriate set method. Then print the value of each of the four fields. This process continues until the user indicates he/she wants to quit.

Once the loop exits, print a Goodbye message.

Reference no: EM131321339

Questions Cloud

Analyze ocbc bank after reading this article : Analyze OCBC Bank after reading this article. Please click on the link, then click on the "Login in as subscriber to read the full article" located at the end of the article, then login with the credentials below. Search for "Putting the 'person' ..
Each project requires net investment outlay : Assume that you are the chief financial officer at Porter Memorial Hospital. The CEO has asked you to analyze two proposed capital investments – Project X and project Y. Each project requires a net investment outlay of $10,000, and the opportunity co..
Simple harmonic motion with an amplitude : A sewing machine needle moves up and down in simple harmonic motion with an amplitude of 1.27 cm and a frequency of 2.55 Hz. What is the maximum speed of the needle? ((answer: 20.3 cm/s))
Construct the register-interference graph for the program : Devise a register-allocation strategy on the assumption that we automatically store all registers on the stack before each procedure call and restore them after the return.
Create an instance of the weightconverter class : Write a driver class that has the main( ) method. This main method should provide the following utility: Create an instance of the WeightConverter class using the default values.
Index of refraction of the soap : Calculate the minimum thickness of a soap bubble film that results in constructive interference in the time reflected light if the film is illuminated with light whose wavelength in free space is λ = 600nm. The index of refraction of the soap film..
Preparing the next section of the diversity training manual : As the new manager of human resources, you are preparing the next section of the diversity training manual, which focuses on making supervisors more aware and sensitive to religious discrimination issues.
What is the final speed of the satellite : An astronaut and a satellite are at rest when the astronaut pushes off from the satellite with a velocity 4.5 m/s (relative to the satellite). If the mass of the astronaut is 60 kg and the mass of the satellite is 3.0 x 102 kg, what is the final s..
Break-even point for the given sales mix : Prepare contribution margins as in part (1) with all revisions - Break-even point for the given sales mix and Margin of safety for the estimated sales volum

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd