CS301 Assignment No. 2 Solution spring 2013

No Comments

Assignment No. 02
SEMESTER Spring 2013
CS301‐ Data Structures


Instructions 
Please read the following instructions carefully before solving & submitting assignment: 

It should be clear that your assignment will not get any credit (zero marks) if: 

o  The assignment is submitted after due date. 
o  The submitted code does NOT compile. 
o  The submitted assignment is other than .CPP file. 
o  The submitted assignment does NOT open or file is corrupted. 
o  The assignment is copied (from other student or ditto copy from handouts or internet). 

Uploading instructions

For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file.
Don’t wait for grace day. Grace day is only given if there is problem on due date. Submit your solution withi
due date.
Note that no assignment will be accepted through email if there is any problem on grace day.

Note: Use ONLY Dev‐C++ IDE.


Objective 
The objective of this assignment is

o  To make  you  familiar  with  queue  and  linked  list  data  structure  and  programming  techniques  to
implement queue as linked list.

For any query about the assignment, contact at cs301@vu.edu.pk
GOOD LUCK



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 stand in 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: 

  •   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.



Lectures Covered:  This assignment covers Lecture #  6‐9 
Deadline:           Your assignment must be uploaded / submitted on / before, Thursday May 02, 2013. 
























Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment