Overloaded Constructors a) Implement a Weight class with a two-parameter setWeight method that initializes weight and units

Question:

Overloaded Constructors

a) Implement a Weight class with a two-parameter setWeight method that initializes weight and units variables and a one-parameter setWeight method that uses a default “kg” for units. Provide corresponding two- parameter and one-parameter constructors and a print method, which displays weight and units values. Minimize the total number of statements by having the one-parameter constructor call the one- parameter setWeight method and the two-parameter constructor call the two-parameter setWeight method.

b) Provide a main method for a WeightDriver class such that the new main method uses one of the new constructors from part a) to generate this output: 

120 lbs

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: