Today in lab, we learned the anatomy of functions. Function header and body, together forming a block of code. They may or may not require arguments or return a value. Afterwards, we were able to create several functions dedicated to calculating values that would add up for our simulated vacation plan.
First, we warmed up by creating one short function that required no arguments and always returned a value.
Now we are ready. First a function was created for calculating the amount of money needed for staying at a hotel for a certain number of nights, every night costs $140.
Then another function is created for the plane ride and returns the appropriate value corresponding to destination
Next was car rental, where it calculates the amount of money needed to pay for renting a car, everyday in possesion requires $40. Apparently this car rental comes with a discount, were if you kept the car for 3 or more days they would drop $20, if it was 5 days or more then they would drop $50.
Now comes the final bit, to add them up together so we can easily get the total required amount of money for the trip.
Forgot to bring some money spend on thing while we take vacation there, just add an extra argument and in the function itself to add them all.
Finally we tested it, lets say we are going to: Los Angeles and staying there for 5 day with $600 in our pocket.
And the vacation trip_cost function works!