Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 1 Object and Instance Before attempting this assignment, be sure you have completed all the reading assignments, non- graded exercises, discussions, and assignments to

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Assignment 1 Object and Instance Before attempting this assignment, be sure you have completed all the reading assignments, non- graded exercises, discussions, and assignments to date. Overview This assignment consists of two classes that will be implemented. A Weight.java class that has three private variables, two private methods and four public methods and a Project.java class that has three private methods. The goal of this assignment is to perform calculations using Weight objects (instances of Weight class). Weight Class Weight class should have three private variables, two private methods and four public methods. Variables Hint: How should/can you access these private variables? 1. A private constant variable called OUNCES IN A_POUND that defines the number of ounces in a pound (16). 2. A private variable called pounds with a data type of integer. 3. A private variable called ounces with a data type of double. Methods 1. A public parameterized constructor, which initializes the private variables. public Weight (int pounds, double ounces) { // implementation2. A private instance method called muuces with a return type of double. This method has no parameters and should return the total number of ounces. For full credit, reuse this method across other methods when possible. 3. A private instance method called normalize with a return type of void. This method has no parameters and should ensure that the number of ounces is less than the number of ounces in a pound. For full credit, reuse this method across other methods when possible. 4. A public instance method called lessTlian with a return type ofbcclean. This method should accept a 1Weight object as a parameter and determine if the object is greater or less than the initialized values. public boolean lessThan {Height weight){ If implementation } 5. A public instance method called addTe with a return type of void. This method should accept a Weight object as a parameter and add the object's weight values to the initialized values. 2. A private class method named findMaximum with a return type of Weight. This method should accept three Weight objects as parameters and compare each Weight object's weight values to find the maximum. The Weight object with the maximum weight value should be returned and then printed using toString in the following format: The maximum weight is x pounds and y ounces where x is the number of pounds and y the number of ounces. Ounces should be displayed with two decimal places. 3. A private class method named findAverage with a return type of Weight. This method should accept three Weight objects as parameters and calculate the average weight value. A new Weight object with the average weight values should be returned and then printed using toString in the following format: The average weight is x pounds and y ounces where x is the number of pounds and y the number of ounces. Ounces should be displayed with two decimal places. 4. A public method named main with a return type of void. This method should exercise the correct functionality of findMinimum, findMaximum and findAverage by creating three5. A public instance method called addTe with a return type of void. This method should accept a Weight object as a parameter and add the ohj ect's weight values to the initialized values. public void addTo {Height weight H implementation } 6. A public instance method called toString with a return type of String. This method has no parameters and should have the following format: it pounds and y ounces where x is the number of pounds and y the number of ounces. Ounces should he displayed with two decimal placms. Projettl Class Project] class should have three private methods and one public method. Methods 1. A private class method named udMinituum with a return type of Weight. This method should accept three Weight objects as parameters and compare each Weight object's weight values to find the minimum. The Weight object with the minimum weight value should he returned and then printed using teString in the followmg format: The minimum weight is x pounds and y ounces where x is the number of pounds and y the number of ounces. Ounces should be displayed with two decimal placm

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

The Ajax company has

Answered: 1 week ago