I`m trying to to use if statement but something going wrong.
statement must be 2 steps
IF There is still room in the array and
IF there is not an Appointmen on the same Date and Time!
Apointment will be accept......
im not getting any error or worning
but its not chaking second if statement and both else printing together

void addAppointmenRecords( )
{  
	int number, i,k;
	system("cls");         //clear screen
		cout<<"\nHow many Appointmen you wish to add? ";
		cin>>number;		   //read number
		cin.get();            //read newline character left in the buffer

	if((number + currentSize ) <= listSize)        //There is still room in the array
	{
	  for( i = 1; i<=number; i++ )
           {
			cout<<"\nEnter Person name: ";
			getline(cin, AppointmenList[currentSize].name);
			cout<<"Enter Appointmen Descriptions: ";
			getline(cin, AppointmenList[currentSize].description);
			cout<<"Enter Appointmen date: ";
			cin>>AppointmenList[currentSize].appdate.day;
			cin>>AppointmenList[currentSize].appdate.mounth;
			cin>>AppointmenList[currentSize].appdate.year;
			cin.get();				//read a character
			cout<<"Enter Appointmen time: ";
            getline(cin, AppointmenList[currentSize].time);
			cout<<endl;
			currentSize += 1; //update CurrentSize
	  
			
	for(k=0; k<currentSize; k++)  //chech if there an Appointmen on the same Date and Time!
if( AppointmenList[currentSize].appdate.day == AppointmenLis[k].appdate.day && 
AppointmenList[currentSize].appdate.mounth == AppointmenList[k].appdate.mounth && 
AppointmenList[currentSize].appdate.year == AppointmenList[k].appdate.year && 
AppointmenList[currentSize].time == AppointmenList[k].time )
			{
		        cout<<"\nGot a match\n";
				cout<<"Appointmen Date and Time already filled"<<endl;
				currentSize-=1;
	        }
			else
			{
				cout<<"Apointment accepted"<<endl;
				currentSize+=1;
			}
	  }
	}
			else
			{
				cout<<"Overflow!!!! Appointmen List is full"<<endl;
				cout<<"\nPress any key to continue"<<endl;
				cin.get();     //read a character
			}
}

I don't get your question, can you please explain it in a way I can understand ?

By the way, If you've some additional time please format your code properly (using code tags was the first (and very good) step, formatting your code is the second one) :) ...

Edit:: Avoid using the system(); command (look here)...

i used the code-tags for my codes
anyway
i was meaning i can still insert Appointmen on the same Date and Time. and printing "Apointment accepted" and
"Appointmen Date and Time already filled" after every entry

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Please, make this terrible code refactoring as soon as possible:
1. Stop using of global variables immediately. Pass appointment list array, its capacity (max size) and a reference to the current free index as addAppointmentRecords arguments.
2. Use operator == for appdate structures instead of these awful member by member comparisons.
3. Use break statement after "already filled" message.
4. Make a proper indentation: it's impossible to read (and understand) this nightmare now...

Next time add main data structures definitions to the snippet. Use code tag with the language specifier (feel the difference):
[code=cplusplus] source

[/code]

I think the curly brackets don't add up correctly you maybe missing some.

I would suggest indenting your code properley to make it more readable.

eg

while(something)
[INDENT]{[/INDENT]
[INDENT][INDENT]if(somethingelse)[/INDENT][/INDENT]
[INDENT][INDENT][INDENT]{[/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT][INDENT]do something[/INDENT][/INDENT][/INDENT][/INDENT]
[INDENT][INDENT][INDENT]}[/INDENT][/INDENT][/INDENT]
[INDENT]}[/INDENT]

Without the extra lines in between.

sorry for my codes everyone im still biginer..
i used code=cplusplus
source
/code
but still looking a bit mess i hope its more readable now.

void addAppointmenRecords( )
{
	system("cls");         //clear screen
	cout<<"\nHow many Appointmen you wish to add? ";
	cin>>number;		   //read number
	cin.get();            //read newline character left in the buffer
	if((number + currentSize ) <= listSize) //There is still room in the array
	{
	  for(int i = 1; i<=number; i++ )
                   {	
		cout<<"\nEnter Person name: ";
		getline(cin, AppointmenList[currentSize].name);
		cout<<"Enter Appointmen Descriptions: ";
		getline(cin, AppointmenList[currentSize].description);
		cout<<"Enter Appointmen date: ";
		cin>>AppointmenList[currentSize].appdate.day;
		cin>>AppointmenList[currentSize].appdate.mounth;
		cin>>AppointmenList[currentSize].appdate.year;
		cin.get();						//read a character
		cout<<"Enter Appointmen time: ";
                                getline(cin, AppointmenList[currentSize].time);
		cout<<endl;
		currentSize += 1; //update CurrentSize
		for(int k=0; k<currentSize; k++) //chech if there an Appointmen on the same Date and Time!
		if( AppointmenList[currentSize].appdate.day == AppointmenList[k].appdate.day && 
		AppointmenList[currentSize].appdate.mounth == AppointmenList[k].appdate.mounth && 
		AppointmenList[currentSize].appdate.year == AppointmenList[k].appdate.year && 
		AppointmenList[currentSize].time == AppointmenList[k].time )
		  {
		      cout<<"\nGot a match\n";
		      cout<<"Appointmen Date and Time already filled"<<endl;
		      currentSize-=1;
		      break;
		  }
		else
		  {
		     cout<<"Apointment accepted"<<endl;
		     currentSize+=1;
		  }
	  }
	}
		else
		   {
		      cout<<"Overflow!!!! Appointmen List is full"<<endl;
		      cout<<"\nPress any key to continue"<<endl;
		      cin.get();     //read a character
		   }
}
Comments
That does already look a lot better :)

Have you tried putting curly brackets after the for loop on line 24?

for()

open with {

if()

open with{

do something

end if with }

end for with}

sorry for my codes i tryed to clean a bit more
its not checking

if there an Appointmen on the same Date and Time!

and printing

"Apointment accepted"

and

Got a match
Appointment Date and Time already filled

can anybody see mistakes now??????

void addAppointmenRecords( )
{  
         int number, i,k;
	system("cls");       //clear screen
	cout<<"\nHow many Appointments do you wish to add? ";
	cin>>number;        //read number
	cin.get();            //read newline character left in the buffer

	if((number + currentSize ) <= listSize)//There is still room in the array
	 {
		for( i = 1; i<=number; i++ )
		 {
			cout<<"\nEnter Person name: ";
			getline(cin, AppointmenList[currentSize].name);
			cout<<"Enter Appointment Descriptions: ";
			getline(cin, AppointmenList[currentSize].description);
			cout<<"Enter Appointment date: ";
			cin>>AppointmenList[currentSize].appdate.day;
			cin>>AppointmenList[currentSize].appdate.mounth;
			cin>>AppointmenList[currentSize].appdate.year;
			cin.get();//read a character
			cout<<"Enter Appointment time: ";
			getline(cin, AppointmenList[currentSize].time);
			cout<<endl;
			currentSize += 1; //update CurrentSize
		     for(k=0; k<currentSize; k++)//check if there an Appointmen on the same Date and Time!
			 {
			   if(AppointmenList[currentSize].appdate.day == AppointmenList[k].appdate.day && 
			   AppointmenList[currentSize].appdate.mounth == AppointmenList[k].appdate.mounth && 
			   AppointmenList[currentSize].appdate.year == AppointmenList[k].appdate.year && 
			   AppointmenList[currentSize].time == AppointmenList[k].time )
				 {
					cout<<"\nGot a match\n";
					cout<<"Appointment Date and Time already filled"<<endl;
					currentSize-=1;
					break;
				 }
				else
				 {
					cout<<"Apointment accepted"<<endl;
					currentSize+=1;
				 }
			 }
		 }
	 }
	else
	 {
		cout<<"Overflow!!!! Appointment List is full"<<endl;
		cout<<"\nPress any key to continue"<<endl;
		cin.get();     //read a character
	 }
}
This article has been dead for over six months. Start a new discussion instead.