Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This program uses functions and variables
- #the main function
- def main():
- print 'Welcome to the meal calculator program'
- print #prints a blank line
- mealprice = input_meal()
- percent = calPercent(mealprice)
- tip = calc_tip(mealprice, percent)
- tax = calc_tax(mealprice)
- total = calc_total(mealprice, tip, tax)
- print_info(mealprice, tip, tax, total)
- #this function will calculate tip at 20%
- def calc_tip(mealprice, percent):
- tip = mealprice * percent
- return tip
- #CalcPercent
- def calPercent(mealprice):
- if mealprice <= 5.99:
- percent = .1
- elif mealprice <= 12 and mealprice >= 6:
- percent = .13
- elif mealprice <= 17 and mealprice >= 12.01:
- percent = .16
- elif mealprice <= 25 and mealprice >= 17.01:
- percent = .19
- elif mealprice >= 25.01:
- percent = .22
- return percent
- #this function will calculate tax at 6%
- def calc_tax(mealprice):
- tax = mealprice * .06
- return tax
- #this function will calculate tip, tax, and the total #cost
- def calc_total(mealprice, tip, tax):
- total = mealprice + tip + tax
- return total
- #this function will print tip, tax, the mealprice, and #the total
- def print_info(mealprice, tip, tax, total):
- print 'The meal price is $', mealprice
- print 'The tip is $', tip
- print 'The tax is $', tax
- print 'The total is $', total
- #this function is for the meal
- def input_meal():
- mealprice = input('Enter the meal price $')
- mealprice = float(mealprice)
- return mealprice
- #calls main
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement