Add to Favorites    Make Home Page 2551 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Data Structures Home » TICKET WINDOW - Program Using Queue.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title TICKET WINDOW - Program Using Queue.
Author AHMAD JUNAID NAZAMI
Author Email junaid123_pk [at] hotmail.com
Description This program demonstrates the working of Queue.It may help
beginners to understand functionalty of queue.
Category C++ » Data Structures
Hits 398529
Code Select and Copy the Code
/*Ticket Window is a simple program to show the implementaion of QUEUE. Program takes as input number of tickets required and ENQUEUE them. Only two tickets are allowed at one time.If more than two tickets are demanded, two are given and the remaining is enqueued again for its turn*/ #include <iostream.h> #include <conio.h> #include <process.h> class ticketqueue{ private: //Data Members int q[5]; int front, rear, noe; //noe..to store number of elements public: //Member Functions ticketqueue(){ noe = rear = front = 0;} //Constructor void enqueue(int); void ticketchecker(); void print(); int isempty(); void queuebuilder(); void menu(); }; ///////////////////// void ticketqueue :: enqueue(int a) { q[rear] = a; rear++; noe++; if (rear == 5) rear = 0; cout<<" "<<a<<" Is Enqeueued....."<<endl; } ///////////////////// void ticketqueue :: ticketchecker() { clrscr(); int not,rt; if ( !isempty() ) { not = q[front]; if (not > 2) { rt = not - 2; if ( rt > 0 ) { enqueue(rt); front++; cout<<" "<<not<<"# Tickets were demanded. 2 Tickets are given. " <<" Enqueued again for next go to get remaining #"<<rt<<" Tickets"<<endl; } else if ( rt <= 0 ) front++; noe--; } else if ( not <= 2 ) { front++; noe--; cout<<" "<<not<<"# tickets are given...."<<endl; } } else cout<<" !!! NO REQUEST IN THE QUEUE " <<endl; getch(); clrscr(); menu(); } ///////////////////// void ticketqueue :: print() { clrscr(); int i = front; if ( noe > 0 ) { cout<<" REQUESTS ENQUEUED ARE :" ; do { cout<<q[i]<<" "; i++; if ( i == 5 ) i = 0; } while ( i != rear ); } else cout<<" NO REQUEST IN QUEUE...QUEUE IS EMPTY "; getch(); clrscr(); menu(); } ////////////////// //Utility Fuction int ticketqueue :: isempty() { if ( noe == 0 ) return 1; else return 0; } ///////////////// //This Function takes input from the user and shows Queue graphically void ticketqueue::queuebuilder(){ clrscr(); int tickets, z = 0, i = 0, x = 20, y = 10, g = 1, h = 17; char c; cout<<"Enter number of tickets to purchase... "<<endl; while (!(c == 'E' || c == 'e')) { if ( z > 4) { clrscr(); cout<<" ERROR!!! Queue Size Violation...Exiting Now "<<endl; getch(); clrscr(); menu(); } else { cout<<" Enter : "; cin>>tickets; enqueue(tickets); z++; gotoxy(17,10); cout<<"->"; gotoxy(20,9); cout<<"----------------------------------"; gotoxy(x,y); cout<<q[i]; x+=2; gotoxy(20,11); cout<<"----------------------------------"; gotoxy(g,h); cout<<"PRESS C/c to CONTINUE E/e to END: "; cin>>c; h += 6; i++; } } getch(); clrscr(); menu(); } ////////////////// void ticketqueue::menu() { int b; gotoxy(15,5); cout<<"Press 1................ENTER NO OF TICKETS "; gotoxy(15,8); cout<<"Press 2................TICKET CHECKER "; gotoxy(15,11); cout<<"Press 3................ALL TICKET REQUESTS "; gotoxy(15,15); cout<<"Press 4................EXIT "; gotoxy(15,18); cout<<"NOW ENTER : "; cin>>b; if ( b == 1 ) queuebuilder(); else if ( b == 2 ) ticketchecker(); else if ( b == 3 ) print(); else if ( b == 4 ) exit(1); } ////////////////// void main() { clrscr(); ticketqueue t; t.menu(); getch(); }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=479


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review