Question: Problem 1 (5 points) Write a Java class named Distance in a file named Distance.java that takes the difference between two distance values as follows.
Problem 1 (5 points) Write a Java class named Distance in a file named Distance.java that takes the difference between two distance values as follows. For example, if one measurement is 7 yards, 2 feet, 11 inches and another is 2 yards, 1 foot, 7 inches, the difference is 5 yards, 1 foot, 4 inches. Prompt the user for each value (first yards, feet, and inches, then second yards feet and inches). Assume the user always enters the larger value first (so you don't have to worry about getting a negative result). Note: You can convert the measures entirely into 'inches', subtract the two values for total inches, and then convert the difference in inches) back into yards, feet and inches before printing the result. Use three sets of integer variables (yard, feet and inches for distance1, distance, and difference) to represent three distance values (note that this s 9 variables totall). Your programa should subtract the first two distance values and store the resuly into the third distance value. If you need to introduce additional variables, feel free to do so Finally, print the three distance values with some annotations ('yards', 'feet', 'inches') so that the result will be meaningful to the user. Example output: First distance: Enter Yards: 7 First distance: Enter Feet: 2 First distance: Enter Inches: 11 Second distance: Enter Yards: 2 Second distance: Enter Feet: 1 Second distance: Enter Inches: 7 Y yards, 2 feet, 11 inches - 2 yards, 1 feet, 7 inches = 5 yards, 1 feet, 4 inches
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
