Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed
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

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

Step: 3

blur-text-image

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions