In: Computer Science
The second assignment involves writing a Python program to
compute the price of a theater ticket. Your program should prompt
the user for the patron's age and whether the movie is 3D. Children
and seniors should receive a discounted price. There should be a
surcharge for movies that are 3D. You should decide on the age
cutoffs for children and seniors and the prices for the three
different age groups. You should also decide on the amount of the
surcharge for 3D movies. Your program should output the ticket
price for the movie ticket based on the age entered and whether the
movie is in 3D.
Your program should include the pseudocode used for your design in
the comments. Document the values you chose for the age cutoffs for
children and seniors, the prices for the three different age groups
and the surcharge for 3D movies in your comments as well.
You are to submit your Python program as a text file (.txt) file.
In addition, you are also to submit a test report in a Word
document or a .pdf file. 15% of your grade will be based on whether
the comments in your program include the pseudocode and define the
values of your constants, 70% on whether your program executes
correctly on all test cases and 15% on the completeness of your
test report.
Short Summary:
Implemented the program as per the requirement
Attached source code and output
**************Please do upvote to appreciate our time. Thank you!******************
Source Code:
#CRITERIA FOR TICKET PRICE
#Age cutOff for children is (<18)
#Age cutOff for Adults is (>18 && <60)
#Age cutOff for Seniors is (>60)
#Regular price of a ticket is 100
#Discounted Price for children and senior citizens is 75
#Surcharge for 3D is 25
#PSEUDOCODE
#x = ask user input age
#y = ask user input 3D or not, Y for yes and N for No
#Call ticket Price calculation function
#if age matches children or senior
#set discounted price
#else
#set regular price
#if 3D
#Add surcharge and return price
#else
#return price
#print Ticket Price
class TicketPriceCalculator(object):
def calculateTicketPrice(self,age,ThreeDInd): #function to
calculate Ticket Price
if age < 18 or age > 60: #check age
ticketPrice=75 #set price
else:
ticketPrice=100
if ThreeDInd.lower() == 'y': #check if 3D
return ticketPrice+25
return ticketPrice
if __name__ == '__main__':
age = input("Enter the age: ") #Ask user for age
ThreeDInd = input("Is the movie 3D? - Y for yes and N for No: ")
#Ask user if movie is 3D or not
ticketPrice=TicketPriceCalculator().calculateTicketPrice(int(age),ThreeDInd)
#Call function to calculate ticketPrice
print("The Price for the ticket is:",ticketPrice) #Print result
Code Screenshot:
Output:
Children with 3D:
Adult with 3D:
Senior without 3D:
**************Please do upvote to appreciate our time.
Thank you!******************