Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me Object and Instance Before attempting this assignment, be sure you have completed all the reading assignments, non- graded exercises, discussions, and assignments
Please help me
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) { // implementation } 2. A private instance method called toOunces 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Code Weightjava a class that represents a Weight in pounds and ounces class Weight private instance variables private int pounds private double ounces a private named constant that defines the number ...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