Program2a and b  - Solution

Program2a and b - Solution

Write a program titled"YourLastName_Program2a" which will read in data from the standard input stream (System.in)representinglength in miles, feet, and inches.The program will then convert the values into meters(using 3.3ft per 1m) and print out the new total value (rounded to the nearest tenth).
*Hint: convert all user input to feet, then convert to meters using the given conversion factor.
For example:
A typical run and the expected output of your program would look like this
(bolded areas represent the user's input):
% java Diaz_Program2a
Enter miles: 1
Enter feet: 26
Enter inches: 13
1 mile(s), 26 feet, 13 inche(s) converts to 1608.2meter(s).
Write a second program titled "YourLastName_Program2b" which then does the reverse conversion (using 1 m per 3.3ft with the results rounded to the nearest tenth).A typical run and the expected output of your program would look like this (bolded areas represent the user's input): *Hint: convert to feet using the given conversion factor, then convert from total feet to miles, feet, and inches.
% java Diaz_Program2b
Enter meters: 1234
1234meters(s) converts to 0mile(s), 4072feet, 2.4inch(es).
Use and submit the following test cases captured in a file by using the command “% script Program2.out”:

Program2a

1 mile, 100 feet, 10 inches
25 miles, 460 feet, 6 inches
0 miles, 1578 feet, 100 inches

Program2b

173 meters
3661 meters
1020 meters
What to turn in:
- Soft copy of the results using the script command
- Soft copy of the programs (the .java file submitted via Blackboard)
Powered by