![]() |
Assignment 06TaskUse conditionals to covert from Imperial (or, more specifically, US customary units) lengths to metric.
Concepts: comparison/relational operators; StepsAsk the user to enter a decimal length in inches, feet, or miles (one of these). Convert this length to centimeters, meters, and kilometers (all three of these). Here are the basic conversion rates you may need to know:
If the user enters an unrecognized unit, give an error message rather than bogus output. You must support these units as input in all cases: "miles", "feet", "inches". (You may also choose to support the singular form of these as well: "mile", "foot", "inch"). You must output the 3 metric results 1 per line. You may use either the full form ("centimeters", "meters", or "kilometers") or the abbreviation ("cm", "m", or "km") for these units. OutputHere's some sample output of 3 different executions: D:\TA\grading\A06>java ZtomaszeA06 This program converts US customary units of length to metric units of length. Enter a length (number) and units (inches/feet/miles) to convert: 3 hands Sorry, but 'hands' is not a unit understood by this program. D:\TA\grading\A06>java ZtomaszeA06 This program converts US customary units of length to metric units of length. Enter a length (number) and units (inches/feet/miles) to convert: 2 miles 2.0 miles equals: 321868.8 centimeters 3218.688 meters 3.218688 kilometers D:\TA\grading\A06>java ZtomaszeA06 This program converts US customary units of length to metric units of length. Enter a length (number) and units (inches/feet/miles) to convert: 0.3937 inches 0.3937 inches equals: 0.999998 centimeters 0.00999998 meters 9.999980000000001E-6 kilometers Tips
What to Submit
Upload your Grading [5 points]
FAQs
|
~ztomasze Index :
TA Details: ICS111:
A06 http://www2.hawaii.edu/~ztomasze |
Last Edited: 21 Sep 2008 ©2008 by Z. Tomaszewski. |