Homework 1
CS1210, Fall 2021
Due Friday, Sep. 3, 2021, by 2:00pm
6 points

Important note: In this assignment no loops, lists, or dictionaries are allowed! Use simple variables, assignments, math expressions, functions, and if/else statements only!

Note: I strongly suggest completing DS Assignment 1 before starting HW1. It will be published Thursday, Aug. 26 and due Tuesday, Aug. 31. The small problems in DS1 will be helpful in HW1. Hints and an outline for completing HW1 will also be given in lecture.

0. Remember! Your submission MUST include the hawkID function (modified with your own hawkID). See the course website and this template file hawkIDtemplate.py. Don't import the template file. Just directly add the code for the hawkID() function into your hw1 Python file.

1. Implement function, computeTripData(distanceK, vehSpeedMPS, vehKPL, gasCostPerLiter, breakfastCostPerDay, lunchCostPerDay, dinnerCostPerDay, hotelCostPerNight) that takes as input:

and returns seven values (in this order): Important rules for cost computation: For example,
>>> computeTripData(1.0, 1000.0/3600, 2.0, 3.0, 5.0, 12.0, 21.0, 111.0)
(1.0, 1.5, 1.5, 0, 0, 0, 0)
>>> computeTripData(31.0, 2000.0/3600, 2.0, 3.0, 5.0, 12.0, 21.0, 111.0)
(15.5, 46.5, 207.5, 1, 2, 1, 1)
>>> computeTripData(80.5, 2000.0/3600, 2.0, 3.0, 5.0, 12.0, 21.0, 111.0)
(40.25, 120.75, 1014.75, 6, 6, 6, 6)
>>> computeTripData(200.0, 3.0, 2.0, 3.0, 5.0, 12.0, 21.0, 111.0)
(18.51851851851852, 300.0, 598.0, 2, 2, 2, 2)
>>>
2. Implement function, printTripSummary(vehName, distanceM, vehSpeedMPH, vehMPG, gasCostPerGallon, breakfastCostPerDay, lunchCostPerDay, dinnerCostPerDay, hotelCostPerNight) that takes as input: Requirements:
  1. printTripSummary must first convert from the US/non-metric input units (miles and gallons) to metric units (kilometers, meters, liters) suitable for passing to Q1's computeTripData function. Important: use good units-conversion constants, not rough/simple approximations like 1.6 km per mile. Good ones are easy to find. I will provide good ones in the slides of one of the upcoming lectures (but you'll have to find them :))
  2. printTripSummary must then make a call to Q1's computeTripData function to get the trip data.
  3. Finally, printTripSummary should construct a string summarizing the trip information, and both print and return that string. The format for the string is shown in the example below. Use the same punctuation and spacing as in the example. Dollar amounts must display two digits after the decimal place (even when it is .00).
For example,
>>> result = printTripSummary("Bugatti", 1400.0, 100.0, 20.0, 5.0, 8.0, 12.5, 24.0, 150.0)
Bugatti trip of 1400.0 miles. Hotel nights: 1, Total cost: $557.00
>>> result = printTripSummary('V1', 100.0, 10.0, 1.0, 5.0, 6.0, 10.0, 23.0, 1000.0)
V1 trip of 100.0 miles. Hotel nights: 1, Total cost: $1539.00
>>> result = printTripSummary('V2', 1231.5, 33.0, 111.0, 10.0, 6.0, 10.0, 23.0, 50.0)
V2 trip of 1231.5 miles. Hotel nights: 4, Total cost: $476.95
>>> printTripSummary('V3', 1231.5, 1.0, 10.0, 10.0, 6.0, 10.0, 23.0, 50.0)
V3 trip of 1231.5 miles. Hotel nights: 183, Total cost: $17528.50
'V3 trip of 1231.5 miles. Hotel nights: 183, Total cost: $17528.50'
>>> 

Submit to ICON one python file containing the required functions. The file must not include any code (except "import math") that is not part of a function definition.
Make sure your functions are named exactly (including upper/lower case usage) as in the specification, with the same set of parameters, in the same order .