Due Date: Wednesday September 2, midnight
Submit your individual file (hw2.py) with the Canvas link.
Reminder that "Individual" means that you should not talk to another student in the class about it. You ARE encouraged to talk to any TA or your lecturer.
Educational goals of this lab - verify that every student can
INSTRUCTIONS:
(50 points) Individual Problem:
To convert from kilometers to miles, you multiply the kilometers by 0.621371. To convert from miles to feet, you multiply the miles by 5280. To convert from feet to yards, divide the feet by 3. This program should input an amount of kilometers and convert it to miles and then to feet and then to yards.
Description | Input kilometers | Expected output miles, feet, yards |
---|---|---|
Normal, integer kilometers | 10 | A. |
Normal, float kilometers | 12.5 | B. |
Boundary, zero kilometers | 0 | C. |
Scientific notation kilometers | 2e4 | D. |
# prolog # GIVE name, section, email address #Purpose: Calculate the equivalent number of miles, feet and yards from kilometers. #Preconditions: FILL THIS OUT #Postconditions: FILL THIS OUT # 1. Get needed data from the keyboard, the number of kilometers. # 2. Calculate the equivalent miles. # 3. Calculate the equivalent number of feet. # 4. Calculate the equivalent number of yards. # 5. Print blank line # 6. Output the input kilometers with label and 3 places. # 7. Output the miles with label and 3 places. # 8. Output the feet with label and 3 places. # 9. Output the yards with label and 3 places.
Test run 1
Enter kilometers: 15.0 15.000 kilometers = 9.321 miles which is 49212.583 feet which is 16404.194 yards
Test run 2
Enter kilometers: 1 1.000 kilometers = 0.621 miles which is 3280.839 feet which is 1093.613 yards
Test run 3
Enter kilometers: 193.45 193.450 kilometers = 120.204 miles which is 634678.281 feet which is 211559.427 yards
Test run 4
Enter kilometers: 0 0.000 kilometers = 0.000 miles which is 0.000 feet which is 0.000 yards