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 program to prints the question

Write a program that prints the question"do you want to continue?" and reads a user input. if the user input is"y", "yes", "ok", "sure", or "why not?".

  Create visual basic windows application

Create Visual Basic Windows application. Use following names for solution and project, respectively: Raise Solution and Raise Project.

  Program display error message if test score is invalid

The program must display suiatble letter grade. The program must display an error message if the test score is 100.

  Write a report of about 900 words that- identifies at least

write a report of about 900 words that- identifies at least 3 users of hr services internal to your organisation and

  Code to sum of all the elements of the array

Write some code that places the sum of all the elements of the array x into total. Declare any variables that you need.

  Write the given fucntions and test

Write the following fucntions and test then in the main without using library or pointer. using only namespace std, and include find_first_of, and find_first_not_of.

  What is access control

What is access control? What is a data classification model? How is data classification different from a clearance leve?

  Write program to compute contestant-s score

Performer's final score is determined by dropping highest and lowest score received, then averaging remaining scores. Write a program which uses this method to compute a contestant's score.

  Problem analysis chart - flowchart

One of your smaller customers' needs your help writing a program. Your customer has an e-commerce Web site but wants to avoid being sued for allowing children to make purchases without the authorization of their parents

  Determine the relative displacement and total acceleration

Determine the relative displacement and total acceleration as functions of time. Then find the peak values of displacement, velocity and total acceleration for different periods and plot the resulting displacement and acceleration response spectra..

  Write program to prompt for and accept current salary

Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases.

  Which array types could hold object references

What is the default initialization value for a character array?

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