Question

In: Computer Science

The second assignment involves writing a Python program to compute the price of a theater ticket....

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.

Solutions

Expert Solution

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!******************


Related Solutions

The sixth assignment involves writing a Python program to read in the temperatures for ten consecutive...
The sixth assignment involves writing a Python program to read in the temperatures for ten consecutive days in Celsius and store them into an array. The entire array should then be displayed. Next each temperature in the array should be converted to Fahrenheit and the entire array should be again be displayed. The formula for converting Celsius to Fahrenheit is °F = (°C × 1.8) + 32. Finally, the number of cool, warm and hot days should be counted and...
This involves writing a Python program to determine the body-mass index of a collection of six...
This involves writing a Python program to determine the body-mass index of a collection of six individuals. Your program should include a list of six names. Using a for loop, it should successively prompt the user for the height in inches and weight in pounds of each individual. Each prompt should include the name of the individual whose height and weight is to be input. It should call a function that accepts the height and weight as parameters and returns...
[PYTHON] Modify the examaverages.py program included with this assignment so it will also compute the overall...
[PYTHON] Modify the examaverages.py program included with this assignment so it will also compute the overall average test grade. E.g if there are 3 test each student must take and the user enters the following set of test scores for the two students…: 30, 40, 50 for the first student 50, 60, 70 for the second student …then program will print the average for each student (i.e. 40 for the first student and 60 for the second student – the...
In Python Suppose there is a movie theater who charges ticket based on ages. Less than...
In Python Suppose there is a movie theater who charges ticket based on ages. Less than 3 years old, free; between 3 to 12, $10; more than 12 years old, $15. Please design a program with loop to, 1) Ask the name then age of the audience, 2) Based on audience's input, tell the audience (with the person's name) how much is the ticket, 3) Stop the program when type in 'quit' in your program.
At a price of $7.75 per ticket, a musical theater group can fill every seat in...
At a price of $7.75 per ticket, a musical theater group can fill every seat in their 1800 seat performance hall. For every additional dollar charged for admission, the number of tickets sold drops by 100. a) What ticket price maximizes revenue? Round your answer to the nearest cent. price = $ equation editor b) How many seats are sold at that price? Round your answer to the nearest whole number. number of seats sold = equation editor
For Python: In this assignment you are asked to write a Python program to determine the...
For Python: In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following: Prompt the user to enter his name. Prompt the user to enter his major. Prompt the user to enter grades for 3 subjects (A, B, C, D, F). Calculate the CGPA of the student. To calculate CGPA use the formula: CGPA = (quality points * credit hours) / credit hours...
Java I'm trying to create a program that replicates a theater ticket reservation system. I have...
Java I'm trying to create a program that replicates a theater ticket reservation system. I have a Seat class with members row(integer), seat(character) and ticketType(character). Where a ticket type can be 'A' adult, 'C' child, 'S' senior, or '.' recorded as empty. I have a Node generic class that points to other nodes(members): up, Down. Left, Right. It also has a generic payload. Lastly, I have an Auditorium class which is also generic. its member is a First Node<T>. As...
In Python This assignment involves the use of text files, lists, and exception handling and is...
In Python This assignment involves the use of text files, lists, and exception handling and is a continuation of the baby file assignment. You should now have two files … one called boynames2014.txt and one called girlnames2014.txt - each containing the top 100 names for each gender from 2014. Write a program which allows the user to search your files for a boy or girl name and display where that name ranked in 2014. For example … >>>   Enter gender...
This project involves writing a program to calculate the terms of the following sequence of numbers:...
This project involves writing a program to calculate the terms of the following sequence of numbers: 0 1 1 3 5 11 21 43 … where each term is twice the second previous term plus the previous term. The 0th term of the sequence is 0 and the 1st term of the sequence is 1. The example below shows how to calculate the next sequence term: Current sequence: 0 1 Calculate next term: 2 * 0 + 1 = 1...
Problem #4 – Logical Operators: Movie Ticket Price The local movie theater in town has a...
Problem #4 – Logical Operators: Movie Ticket Price The local movie theater in town has a ticket price of $12.00. But, if you are a senior (55 and older), or are under 10, or are seeing a matinee which screens from 3 pm to 5 pm, you get the discounted price of $7.00, nice! Hint 1: "55 and older" is INCLUSIVE Hint 2: under 10 is EXCLUSIVE Hint 3: the range 3 to 5 is INCLUSIVE Hint 4: limit 1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT