I am doing this code for my university project, I tried it with getter functions but it was not running either and it is not assigning values to the class member and not displaying the values back and Neither search modify functions are working it seems they are not able to access the class members, I am working on it for more than hours and know I cannot get any idea why is it not working, Can anybody help?
#include<iostream>
#include<string>
using namespace std;
void intro();
void entry_menu();
void getdata();
void display();
void search();
void Modify();
int count;
class student {
public:
string name[50];
string fname[50];
string regNo[50];
int rollNo[50];
void getdata();
void showdata();
void search();
int numberstudents;
};
class course {
public:
string courseId;
string courseName;
void getdata();
void showdata();
void availableCourse();
};
class transcript {
public:
int currentSemester;
int previousSemester;
void getdata();
void showdata();
};
class fee {
};
student s;
int main() {
char choice=0;
intro();
do
{
system("cls");
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. ENTRY/EDIT MENU";
cout<<"\n\n\t02. FEE";
cout<<"\n\n\t03. TRANSCRIPT";
cout<<"\n\n\t04. EXIT";
cout<<"\n\n\tPlease Select Your Option (1-4) ";
cin>>choice;
switch (choice)
{
case '1': entry_menu();
break;
case '2':
break;
case '3':
break;
default:cout << "\a";
}
} while (choice!= '4');
return 0;
}
void intro()
{
cout<<"\n\n\n\t\t =============================================================================";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || STUDENT ||";
cout<<"\n\n\t\t || MANAGEMENT ||";
cout<<"\n\n\t\t || SYSTEM ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t || ||";
cout<<"\n\n\t\t ||===========================================================================||";
cout<<endl<<" *****Press Enter***** "<<endl;
cin.get();
}
void entry_menu()
{
char ch;
int num;
system("cls");
cout << "\n\n\n\tENTRY MENU";
cout << "\n\n\t1.CREATE STUDENT RECORD";
cout << "\n\n\t2.DISPLAY ALL STUDENTS RECORDS";
cout << "\n\n\t3.SEARCH STUDENT RECORD ";
cout << "\n\n\t4.MODIFY STUDENT RECORD";
cout << "\n\n\t5.DELETE STUDENT RECORD";
cout << "\n\n\t6.BACK TO MAIN MENU";
cout << "\n\n\tPlease Enter Your Choice (1-6) ";
cin >> ch;
system("cls");
switch (ch)
{
case '1':
getdata();
break;
case '2':
display();
break;
case '3':
search();
break;
case '4':
Modify();
break;
}
}
void getdata(){
cout<<"Enter The Number of students who's data you want to enter: ";cin>>s.numberstudents;
cout<<"***********************Enter The Data of the Students****************************"<<endl;
for(int i=0;i<=s.numberstudents-1;i++){
cout<<"\n\nEnter The Name of the Student ";
cin.ignore();
getline(cin,s.name[i]);
cout<<"\n\nEnter The Father Name of the Student ";
cin.ignore();
getline(cin,s.fname[i]);
cout<<endl;
cout<<"Enter Registration Number: ";
cin.ignore();
getline(cin,s.regNo[i]);
cout<<endl;
cout<<"Enter Roll Number: ";
cin>>s.rollNo[i];
system("cls");
}
cout<<"You have successfully saved "<<s.numberstudents<<" records\n";
}
void display(){
for(int j=0; j<=s.numberstudents-1; j++)
{
cout<<"\n\nThe Name of the Student ";
cout<<s.name[j];cout<<endl;
cout<<"\n\nThe Father Name of the Student ";
cout<<s.fname[j];cout<<endl;
cout<<"Registration Number: ";
cout<<s.regNo[j];cout<<endl;
cout<<"Roll Number: ";
cout<<s.rollNo[j];cout<<endl;
}
}
void search(){
int srchCat,srchID,flag;
string srchNam; //These will ask what the user wants to search
cout<<"What do you wish to search?"<<endl;
cout<<"1 for Roll No"<<endl;
cout<<"2 for Name"<<endl<<endl;
cin>>srchCat;
cout<<endl;
if (srchCat==1){
cout<<"Enter Roll No: ";
cin>>srchID;
for (count=0; count<10; count++){
if (srchID==s.rollNo[count]){
flag=1;
break;
}
}
if (flag==1)
cout<<"This ID belongs to "<<s.name[count]<<endl;
else
cout<<"Not Found"<<endl;
}
if (srchCat==2){
cout<<"Enter Name: ";
cin.ignore();
getline(cin,srchNam);
for (count=0; count<10; count++){
if (srchNam==s.name[count]){
flag=1;
break;
}
}
if (flag==1)
cout<<"This student has ID "<<s.rollNo[count]<<endl;
else
cout<<"Not Found"<<endl;
}
}
void Modify(){
bool found;
string edit;
cout<<"please enter name or father name of student for search to add his record\n";
cin.ignore();
getline(cin,edit);
for(int j=0; j<=count;j++)
{
if(edit==s.name[j] || edit==s.fname[j])
{
cout<<"Old record \n"<<"student name : "<<s.fname[j]<<endl<<"Father name : "<<s.name[j]<<endl<<"Student roll no : "
<<s.rollNo<<endl;
cout<<"please enter new record\n";
getline(cin,s.name[j]);
cout<<"please enter new student father name\n";
getline(cin,s.fname[j]);
cout<<"please enter new roll no\n";
cin>>s.rollNo[j];
system("cls");
cout<<"you have successfuly re-edit the date\n";
found=1;
}
}
if(found==0)
{
cout<<"Not found\n";
}
}