Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write in Java public Weight() : The default constructor for the class, which ini

ID: 3693838 • Letter: W

Question

Write in Java

public Weight(): The default constructor for the class, which initializes the object to INIT_VAL kilograms. Both variables must be set using explicit assignment statements.

The following is some output from my completed solution using the Hw4.java driver program:

0.0 kilograms is 0.0 pounds.
0.0 kilograms is 0.0 pounds.

Entering first weight ...
Please enter the weight scale (p/k):$
pounds and kilograms are the only valid scales
Please enter the weight scale (p/k):*
pounds and kilograms are the only valid scales
Please enter the weight scale (p/k):#
pounds and kilograms are the only valid scales
Please enter the weight scale (p/k):P
Please enter a weight measurement (a non-negative value): -3
The weight measurement must be greater than or equal to 0.0.
Please enter a weight measurement (a non-negative value): -2
The weight measurement must be greater than or equal to 0.0.
Please enter a weight measurement (a non-negative value): -1
The weight measurement must be greater than or equal to 0.0.
Please enter a weight measurement (a non-negative value): 0.5
Entering second weight ...
Please enter the weight scale (p/k):K
Please enter a weight measurement (a non-negative value): 23.4
0.2268 kilograms is 0.5 pounds.
23.4 kilograms is 51.480000000000004 pounds.
Do you wish to continue (y/n)?y

Entering first weight ...
Please enter the weight scale (p/k):K
Please enter a weight measurement (a non-negative value): 5
Entering second weight ...
Please enter the weight scale (p/k):P
Please enter a weight measurement (a non-negative value): 10
5.0 kilograms is 11.0 pounds.
4.536 kilograms is 10.0 pounds.
Do you wish to continue (y/n)?n

Goodbye!

Explanation / Answer

import java.util.Scanner; public class Exercise04_03 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Kilograms" + " " + "Pounds "); int number = 0, i = 1; double conversion = number * 0.45359237; while (number
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote