CS301 Data Structures Assignment No. 2 Solution Spring 2013


Suppose three movies (Harry Potter, English Vinglish and Tekken) are on display in a cinema. Three different counters are distributing tickets for each movie. To purchase a particular movie ticket, you are required to standing the respective movie counter queue.

Considering the above scenario, write a C++ program which asks a user to choose the movie for which he/she would like to purchase a Ticket. While choosing the movie ticket, user should be asked to enter his/her social group [F for female, M for male and K for kids].

The required program functionalities should be:

Sponsored Links

> Take input for all the three movies.
> Display the total number of visitors for each movie.
> Display total revenue of cinema and total revenue of each movie (Suppose price of one ticket is 650/-).
> Display the best business earning movie of the cinema.
> Check the popularity of each movie amongst social groups (females, males or kids).

Solution Guidelines:

1) To purchase the movie ticket, viewer must have to stand in the queue. The length of the queue can vary so you have to implement queue as link list.

2) Create a class named Viewer (Node class); this class should create a node for each ticket. This class should define two private data members, social group and Next pointer. A constructor, getter and setter functions for each data member should also be defined in this class.

Note: While getting the value for social group, restrict the user to only enter ‘f’ or ‘F’ for female, ‘m’ or’ M’ for male and ‘k’ or ‘K’ for kids.

3) Create another class named Mov_Que (List class); to create a queue for each movie, this class should define three variables, Front pointer, Rear pointer and counter. The class should also define the following functions:
a) Constructor(): Default constructor of the class.
b) Destructor(): Destructor to destroy the memory gained by the use of new operator.
c) add_Ticket(): This method should enter the new ticket purchased at the rear.
d) Total_Visitors(): This method should return the total number of visitors of movie.
e) Total_Revenue(): This method should return the total revenue of the movie.
f) Popularity(): This method should check the popularity of the movie amongst social group, whether the movie is popular among males, females or kids.

4) In main() function of the program, create three objects of the class Mov_Que which will act like three counters at cinema. These objects should be able to perform all the required functionalities mentioned in the question statement.

5) To get the idea about exact output of program, see Demo.wmv file attached with assignment file.