//**************************From I_am Pakistan*****************************/ //**************************www.vustudents.ning.com*****************************/ #include<iostream.h> #include<conio.h> #include<stdlib.h> using namespace std; void bestSeller(double,double,double); class Node { private: char SocialGroup; Node * Next; public: void setSocialGroup(char sg){ SocialGroup=sg; } char getSocialGroup() { return SocialGroup; } void setNext(Node *n){ Next=n; } Node *getNext(){ return Next; } }; class Queue { Node * front; Node * rear; static int visitor; int harrypotter_ticket; int englishvinglish_ticket; int takken_ticket; int male; int female; int kids; public : Queue() { front=new Node(); front->setSocialGroup('\0'); front->setNext(NULL); rear=NULL; harrypotter_ticket=0; englishvinglish_ticket=0; takken_ticket=0; male=0; female=0; kids=0; } ~Queue() { cout<<"\nObject Deleted"; } void addTicket(char s,int c) { Node *node=new Node(); node->setSocialGroup(s); switch(c){ case 1: harrypotter_ticket++; group(s); break; case 2: englishvinglish_ticket++; group(s); break; case 3: takken_ticket++; group(s); break; default: break; } if(rear!=NULL){ node->setNext(rear->getNext()); rear->setNext(node); rear=rear->getNext(); visitor++; } else{ rear =node; rear->setNext(front->getNext()); front->setNext(rear); visitor++; }} void group(char g) { if(g=='m' || g=='M') {male++;} else if(g=='f' || g=='F') {female++;} else {kids++;} } int totalVisitors(int c) { if(c==0) { return visitor; // sum of all visitors } if(c==1) { return harrypotter_ticket; } else if(c==2) { return englishvinglish_ticket; } else { return takken_ticket; }} double totalRevenue(int c) { if(c==1) { return ((double)harrypotter_ticket*650); } else if(c==2) { return ((double)englishvinglish_ticket*650); } else if(c==3) { return ((double)takken_ticket*650); }} void papolarity(char *movie) { if(male>female && male>kids) { cout<<movie<<" is popular among Males\n"; } else if(female>kids) { cout<<movie<<" is popular among Female\n"; } else if(kids>female) { cout<<movie<<" is popular among Kids\n"; } else { cout<<movie<<" has Average Popularity\n"; }} void dequeueVisitors(int num) { for(int i=0;i<num;i++) { Node *temp=front; front=front->getNext(); delete temp; }}}; int Queue::visitor; main() { Queue *harry_potter= new Queue(); Queue *english_vinglish= new Queue(); Queue *takken= new Queue(); char choice; int tot_visitors; int HP_visitors=0; int EV_visitors=0; int TK_visitors=0; double HP_revenue=0; double EV_revenue=0; double TK_revenue=0; char group; char YesNo; bool loop=true; cout<<"Enter 1 for Harry Potter\nEnter 2 for English Vinglish\nEnter 3 for Takken\n"; cout<<"----------------------------\n"; while(loop) { label1: cout<<"Kindely Enter Correct Choice(1-3): "; cin>>choice; switch(choice) { case '1': socialGroup1: cout<<"Enter your Social Group(M for male , F for femal and K for kid) "; cin>>group; if(group=='m' || group=='M' || group=='f' || group=='F' || group=='k' || group=='K') { harry_potter->addTicket(group,1); HP_visitors=harry_potter->totalVisitors(1); HP_revenue=harry_potter->totalRevenue(1); } else { cout<<"**Invalid Input for Social Group**\n"; goto socialGroup1; } break; case '2': socialGroup2: cout<<"Enter your Social Group(M for male , F for femal and K for kid) "; cin>>group; if(group=='m' || group=='M' || group=='f' || group=='F' || group=='k' || group=='K') { english_vinglish->addTicket(group,2); EV_visitors=english_vinglish->totalVisitors(2); EV_revenue=english_vinglish->totalRevenue(2); } else { cout<<"**Invalid Input for Social Group**\n"; goto socialGroup2; } break; case '3': socialGroup3: cout<<"Enter your Social Group(M for male , F for femal and K for kid) "; cin>>group; if(group=='m' || group=='M' || group=='f' || group=='F' || group=='k' || group=='K') { takken->addTicket(group,3); TK_visitors=takken->totalVisitors(3); TK_revenue=takken->totalRevenue(3); } else { cout<<"**Invalid Input for Social Group**\n"; goto socialGroup3; } break; default: cout<<"Invalide Input\n"; goto label1; break; } label2: cout<<"Do you want to buy Another Ticket (Y/N): "; cin>>YesNo; if(YesNo=='y' || YesNo=='Y') { loop=true; } else if(YesNo=='n' || YesNo=='N') { loop=false; } else { cout<<"\n**(PLease Enter Correct Word)**\n"; goto label2; } } system("cls"); cout<<endl<<"******* Response of Each Movie **************\n"; cout<<endl<<"Total Number of tickets sold for Harry Potter: "<<HP_visitors; cout<<endl<<"Total Number of tickets sold for Harry English Vinglish: "<<EV_visitors; cout<<endl<<"Total Number of tickets sold for Takken: "<<TK_visitors<<endl; cout<<"\n******* Revenue generated By each Movie **************\n"; cout<<endl<<"Harry Potter Revenue: "<<HP_revenue; cout<<endl<<"English Vinglish Revenue: "<<EV_revenue; cout<<endl<<"Takken Revenue: "<<TK_revenue<<endl; cout<<"\nTotal revenue of the cenima is "<<HP_revenue+EV_revenue+TK_revenue<<endl<<endl; bestSeller(HP_revenue,EV_revenue,TK_revenue); cout<<"\n******* PoPularity of each Movie Among Social Group**************\n\n"; harry_potter->papolarity("Harry Potter"); english_vinglish->papolarity("English Vinglish"); takken->papolarity("Takken"); harry_potter->dequeueVisitors(HP_visitors);// delete all harry potter visitors english_vinglish->dequeueVisitors(EV_visitors); // delete all English Vinglsh visitors takken->dequeueVisitors(TK_visitors);//// delete all Takken visitors delete harry_potter; delete english_vinglish; delete takken; cout<<"\n********* From i_am Pakistan**************"; cout<<endl<<"*********www.vustudents.ning.com***********"; getch(); } void bestSeller(double x,double y,double z) { if(x>y && x>z) { cout<<"Harry Potter is the Best Seller Movie of the Cenima"; } else if(y>z) { cout<<"English Vinglish is the Best Seller Movie of the Cenima"; } else if(z>y) { cout<<"Takken is the Best Seller Movie of the Cenima"; } else { cout<<"Average Sale"; }}
We tried that Assignment Solution, Graded Discussion Solution,Announcement
Search with our Site
Custom Search
Monday, April 29, 2013
CS301 Assignment # 2 Solution 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment