Question: Activity 5 : Write a program to calculate trip costs of an employee. The trip cost includes costs of the following: a ) Flight round
Activity : Write a program to calculate trip costs of an employee. The trip cost includes costs of the following:
a Flight round trip cost
b Hotel cost for x number of days
c Car rental cost
Steps:
Use functions to calculate your trip's costs:
Define a function called hotelcost with one argument nights as input. The hotel costs $ per night. So the function hotelcost should return nights.
Define a function called planeridecost that takes a string, city, as input. The function should return a different price depending on the location, similar to the code example above. Below are some valid destinations and their corresponding roundtrip prices.
"Napier":
"Auckland":
"Christchurch":
"Dunedin":
Define a function called rentalcarcost with an argument called days. Calculate the cost of renting the car: Every day you rent the car costs $costdays if you rent the car for or more days, you get $ off your totalcost
Alternatively elif if you rent the car for or more days, you get $ off your total.
You cannot get both of the above discounts. Return that cost.
Finally define a function called tripcost that takes two arguments, city and days. Like the example above, have your function return the sum of calling the rentalcarcostdays hotelcostdays and planeridecostcity functions.
Modify your tripcost function definition. Add a third argument, spendingmoney. Modify what the tripcost function does. Add the variable spendingmoney to the sum that it returns.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
