#Josh Roybal #CIS 122 #Chapter 7 Exercise #2 def incomeGenerated(sectionA, sectionB, sectionC): if sectionA >= 0 and sectionA <= 300: if sectionB >= 0 and sectionB <= 500: if sectionC >= 0 and sectionC <= 200: totalIncome = (sectionA * 20) + (sectionB * 15) + (sectionC * 10) print('Total income for tonight: $', totalIncome, '. \n') else: print('Invalid number of seats for Section C. \n') else: print('Invalid number of seats for Section B. \n') else: print('Invalid number of seats for Section A. \n') def main(): keepGoing = 1 while keepGoing == 1: sectionA = int(input('Please enter the number of tickets sold in Section A: ')) sectionB = int(input('Please enter the number of tickets sold in Section B: ')) sectionC = int(input('Please enter the number of tickets sold in Section C: ')) incomeGenerated(sectionA, sectionB, sectionC) promptChar = input("Would you like to make another calculation? (Y or N): ") if promptChar == 'n' or promptChar == 'N': print("Exiting program...") keepGoing = 0 else: print("Continuing program!") keepGoing = 1 main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question