We're having a problem about Circular Queue Implementation,
We are directed to create any small system that will use the solution circular queue that will act like a linked list. So far my we had edited the Circular queue code that our teacher given us, but the code she had given only use int types and can only manipulate one data only. We don't have any clue on how to pass numerous data to every array of the circular queue that will act like a node storage. We're trying to pass a structure to the enqueue function, but we can only insert 1 char only...instead of a whole string...
this is the code we formulated but can only input one characters at every needed data..we are having problems also on the deletion and display...
THANK YOU...we are really trying our best to finish this...not just for the requirement but our priority is to learn the algorithm behind for our future field in programming
WE will appreciate all of the help and suggestions thank you
#include<iostream>
#define SIZE 10
using namespace std;
struct info{
int month[SIZE];
int day[SIZE];
int year[SIZE];
char ownername[SIZE];
char petname[SIZE];
char specie[SIZE];
char breed[SIZE];
};
void insert(char y[],char z[],char a[],char b[],int m[],int d[],int yr[]);
//void del(char y[],char z[],char a[],char b[],int m[],int d[],int yr[]);
void update(char y[],char z[],char a[],char b[],int m[],int d[],int yr[]);
void searchanddisplay(char y[],char z[],char a[],char b[],int m[],int d[],int yr[]);
//void display(char y[],char z[],char a[],char b[],int m[],int d[],int yr[]);
int front=-1;
int rear=-1;
int main()
{
info a;
while(1)
{
int choice;
system("cls");
cout<<"*****Pet's GROOMING CENTER*****\n\n"
<<"MENU: \n"
<<"[1] INSERT\n"
<<"[2] DELETE\n"
<<"[3] UPDATE\n"
<<"[4] SEARCH AND DISPLAY\n"
<<"[5] DISPLAY ALL DATA\n"
<<"[6] EXIT\n"
<<"------------------------------------------\n\n"
<<"Please Enter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
{
insert(a.ownername,a.petname,a.specie,a.breed,a.month,a.day,a.year);
break;
}
/*case 2:
{
del(a.ownername,a.petname,a.specie,a.breed,a.month,a.day,a.year);
break;
}*/
case 3:
{
update(a.ownername,a.petname,a.specie,a.breed,a.month,a.day,a.year);
break;
}
case 4:
{
searchanddisplay(a.ownername,a.petname,a.specie,a.breed,a.month,a.day,a.year);
break;
}
/*case 5:
{
display(a.ownername,a.petname,a.specie,a.breed,a.month,a.day,a.year);
break;
}*/
case 6:
{
exit(1);
}
default:
{
cout<<"Sorry. You have entered a wrong value.\n";
}
}
cout<<endl;
system("pause>0");
}
return 0;
}
void insert(char y[],char z[],char a[],char b[],int m[],int d[],int yr[])
{
int t=0;
if(front==-1)
{
front=0;
rear=0;
cout<<"Welcome! You are costumer no. "<<rear;
cout<<"\nOwner's name: ";
cin>>y[rear];
cin.ignore();
cout<<"Pet's name: ";
cin>>z[rear];
cin.ignore();
cout<<"Specie: ";
cin>>a[rear];
cin.ignore();
cout<<"Breed: ";
cin>>b[rear];
cin.ignore();
cout<<"\nDate of consultation: ";
while(t==0)
{
cout<<"\nmonth: ";
cin>>m[rear];
if(m[rear]>12)
{
cout<<"\nmonth entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
while(t==0)
{
cout<<"\nday: ";
cin>>d[rear];
if(d[rear]>31)
{
if(m[rear]==2){
if(d[rear]>29){
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
}
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
cout<<"\nYear:";
cin>>yr[rear];
}
else if((rear+1)%SIZE==front)
cout<<"Sorry, system is already full.";
else
{
rear=(rear+1)%SIZE;
cout<<"Welcome! You are costumer no. "<<rear;
cout<<"\nOwner's name: ";
cin>>y[rear];
cin.ignore();
cout<<"Pet's name: ";
cin>>z[rear];
cin.ignore();
cout<<"Specie: ";
cin>>a[rear];
cin.ignore();
cout<<"Breed: ";
cin>>b[rear];
cin.ignore();
cout<<"\nDate of consultation: ";
while(t==0)
{
cout<<"\nmonth: ";
cin>>m[rear];
if(m[rear]>12)
{
cout<<"\nmonth entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
while(t==0)
{
cout<<"\nday: ";
cin>>d[rear];
if(d[rear]>31)
{
if(m[rear]==2){
if(d[rear]>29){
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
}
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
cout<<"\nYear:";
cin>>yr[rear];
}
}
//void del(char y[],char z[],char a[],char b[],int m[],int d[],int yr[])
//{
//}
void update(char y[],char z[],char a[],char b[],int m[],int d[],int yr[])
{
int edit;
int t=0;
cout<<"Please Enter The Costumer no. of the data you want to update: ";
cin>>edit;
if(edit>rear)
cout<<"Data doesn't exist.";
cout<<"\nOwner's name: ";
cin>>y[edit];
cin.ignore();
cout<<"Pet's name: ";
cin>>z[edit];
cin.ignore();
cout<<"Specie: ";
cin>>a[edit];
cin.ignore();
cout<<"Breed: ";
cin>>b[edit];
cin.ignore();
cout<<"\nDate of consultation: ";
while(t==0)
{
cout<<"\nmonth: ";
cin>>m[edit];
if(m[edit]>12)
{
cout<<"month entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
while(t==0)
{
cout<<"\nday: ";
cin>>d[edit];
if(d[edit]>31)
{
if(m[edit]==2){
if(d[edit]>29){
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
}
cout<<"\nday entered doesn't exist.";
system("pause>0");
}
else
t=1;
}
t=0;
cout<<"\nYear:";
cin>>yr[edit];
cout<<"You have successfully updated the data.";
}
void searchanddisplay(char y[],char z[],char a[],char b[],int m[],int d[],int yr[])
{
int search;
cout<<"Please enter the costumer number you want to search and display: ";
cin>>search;
if(search>rear)
cout<<"\n\nData doesn't exist.";
cout<<"Data found: \n";
cout<<"\nOwner's Name: "<<y[search];
cout<<"\nPet's Name: "<<z[search];
cout<<"\nSpecie: "<<a[search];
cout<<"\nBreed: "<<b[search];
cout<<"\nDate of consultation: "<<m[search]<<"/"<<d[search]<<"/"<<yr[search];
}
//void display(char y[],char z[],char a[],char b[],int m[],int d[],int yr[])

New Topic/Question
Reply




MultiQuote





|