Help! need to solve with function overloading.

I am quite confused to solve this problem. The requirement was to solve by using function overloading. The variables that needed to pass are Name,ID,Phone.
Please do help. Your guidance are very needed.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <strings.h>

using namespace std;


void student();
char student(char,char,char);
void end();
int main();

void student()
{
	char Name[20],ID[10] ,Phone[10];
	char ans;
	do
	{
		system ("cls");
		cout<<"\t\t"<<"Welcome To Sem 1, 2014"<<endl<<endl;
		cout<<"\t"<<"Please Enter Your Name: ";
		cin>>Name;
		cout<<endl<<endl<<"\t"<<"Please Enter Your Student ID: ";
		cin>>ID;
		cout<<endl<<endl<<"\t"<<"Please Enter Your Contact Number <without space/dash/symbol>: ";
		cin>>Phone;
		cout<<"\t";
		system ("pause");
		cout<<"\t"<<"Would you like to check your entry? <Y/N>: ";
		cin>>ans;
		if(ans=='y'||ans=='Y')
		{
			student(Name,ID,Phone);
		}
		else
		{
			main(Name,ID,Phone);
			break;
		}	
	}while(ans=='n'||ans=='Y');
			
}

char student(char Name[20],char ID[10],char Phone[10])
{
	int result=0;
	char checkID[10],retry;	
	do
	{
		system ("cls");
		cout<<endl<<endl<<"\t\t"<<"Welcome To Sem 1,2014"<<endl<<endl;
		cout<<endl<<endl<<"\t"<<"Please enter your Student ID to validate entry. :";
		cout<<endl<<"\t"<<"Student ID: ";
		cin>>checkID;
		if(strcmp(checkID,ID)==0)
		{
			cout<<"\t\t"<<"Welcome To Sem 1, 2014"<<endl<<endl;
			cout<<endl<<endl<<"\t"<<"Name: "<<Name<<endl;
			cout<<endl<<endl<<"\t"<<"Your Student ID: "<<ID<<endl;
			cout<<endl<<endl<<"\t"<<"Your Contact Number <without space/dash/symbol>: "<<Phone<<endl;
			system ("pause");
	
		}
		else 
		{
			system ("cls");
			cout<<"\t"<<"Sorry. The system has identified either one of the following:"<<endl<<endl<<"\t"<<"a. You have entered and invalid ID."<<endl<<endl<<"\t\t"<<"OR"<<endl<<endl<<"\t"<<"b. You have not registered the ID option in Option #1."<<endl<<endl;
			cout<<"\t\t";
			system ("pause");
			cout<<"\t\t"<<"Please select:-"<<endl;
			cout<<"\t\t"<<"a. To re-enter your student ID."<<endl;
			cout<<"\t\t"<<"b. To return to main menu."<<endl;
			cout<<"\t\t"<<"Selection: ";
			cin>>retry;
			system("cls");
			if (retry=='a'||retry=='A')
				{
							cout<<endl<<"\t\t Reverting back to Input selection..."<<endl;
				}
			if (retry=='b'||retry=='B')
				{
					cout<<endl<<"\t\t"<<"Reverting to Main Menu Slection..."<<endl;
					break;
		                }
		Sleep(1000);	
		}
					
	  }while(strcmp(checkID,ID)!=0);
	cout<<endl<<"\t\t";
	system("pause");
	main();		
}

void end()
{
			char ans;
			cout<<"\t"<<"Are you sure you want to exit? <Y?N>: ";
			cin>>ans;
			if (ans=='y'||ans=='Y')
			{
				exit(0);
			}	
			else
			{
				main();
			}
}

int main()
{
	char option;
	
	do {
		system("cls");
		cout<<"\t\t"<<"Welcome To Sem 1,2014"<<endl<<endl;
		cout<<"\t"<<"Please select your option:-"<<endl<<endl;
		cout<<"\t"<<"1- Input Students Details"<<endl<<endl;
		cout<<"\t"<<"2- Display Students Details"<<endl<<endl;
		cout<<"\t"<<"3- EXIT Program"<<endl<<endl;
		cout<<"\t"<<"Selection: ";
		cin>>option;
		switch(option)
		{
			case '1':{
				system ("cls");
				student();
				break;
				}
			case '2':{
			        system ("cls");
			        student(Name,ID,Phone);
			        break;
					           }
			case '3':{
		                 end();
				 break;
				}	
			default:{
                                 cout<<"\t"<<"Please enter 1,2 or 3 only!";
                                 cout<<endl<<"\t";
		                 system ("pause");
			         break;
				}		
		}
		
	}while(option!=3);
		
	 	
}
Topic archived. No new replies allowed.