Create a Movies class that determines the cost of a ticket to a cinema, based on the moviegoer’s age. Assume that the cost of a full-price ticket is $10. Assign the age to a private data member. Use a public member function to determine the ticket price, based on the follow- ing schedule: Age Price Under 5 Free 5 to 17 Half price 18 to 55 Full price Over 55 $2 off
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a Movies class that determines the cost of a ticket to a cinema,
based on the moviegoer’s age. Assume that the cost of a full-price ticket is $10. Assign the age to a private data member. Use a public member function to determine the ticket price, based on the follow- ing schedule: Age Price Under 5 Free 5 to 17 Half price 18 to 55 Full price Over 55 $2 off
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images