C++ Project on College Registration
Features
- Add student record
- Update student record
- Display student record
- Add modules
- Display module details
- Update Module
Source Code
#include
#include
#include
#include
#include
using namespace std;
char stdsRec[] = "stdtRecord.txt";
char modulesRecord[] = "modRecord.txt";
char tempFile[] = "tempFile.txt";
class Std{
public:
//add one std's record to DB
int addStdRecord(char *stdsRec){
int StdNo;
char name[50];
ofstream out(stdsRec, ios_base::app);
cout<<"\nEnter Std No : ";
cin>>StdNo;
out<>name;
out<>flag;
int moduleCount =-1;
if(flag==0)
moduleCount = 6;
else if(flag ==1)
moduleCount = 4;
else{
cout<<"\nErr: Pl. enter either 0or1 ";
return -1;
}
for(int i=0; i>module;
out<>choice;
//separator to find start of marks
out<<" = ";
if(choice=='y')
{
for(int i=0; i>marks;
out<>StdNo;
//modify if it exist e
}
//display record of any Std by his Stdno
int displayStdRecord(){
int StdNo;
//display if Std record exist
cout<<"\n# Find Any Module Details #\n";
cout<<"\nEnter Std No to be searched: ";
cin>>StdNo;
int flag = -1;
ifstream file(stdsRec);
string str;
while (getline(file, str))
{
if(str.length()>0){
char temp[1000];
memset(temp,1000,sizeof(temp));
strcpy(temp, str.c_str());
char * ptr;
ptr = strtok(temp ,"|");
int tempno = atoi(ptr);
if(StdNo == tempno )
{
cout<<"\n"<0)
cout<<"\n\t"<>StdNo;
int flag = -1;
ifstream file(stdsRec);
string str;
while (getline(file, str))
{
if(str.length()>0){
char temp[1000];
memset(temp,1000, sizeof(temp));
strcpy(temp, str.c_str());
char * ptr;
ptr = strtok(temp ,"|");
int tempno = atoi(ptr);
if(StdNo == tempno )
{
memset(temp,1000,sizeof(temp));
strcpy(temp, str.c_str());
char *ptr1 = strtok(temp, "=");
ptr1 = strtok(NULL,"=");
//cout<<"\n====> "< "<70) cout<<"\nGrade : A";
else if(sum>=60 && sum<=69)
cout<<"\nGrade is : B+";
else if(sum >=50 && sum<=59)
cout<<"\nGrade is : B";
else if(sum>=41 && sum<=49)
cout<<"\nGrade is : C";
else if(sum>=40)
cout<<"\nGrade is : D";
else if(sum<40)
cout<<"\nGrade is: F";
}
else{
sum = sum / 4;
cout<<"\nAvg Sum of 4 sub : "<< sum;
if(sum>= 76) cout<<"\nDistinction";
else if(sum>=61 && sum<=75 )
cout<<"\nMerit";
else if(sum>=50 && sum<=60)
cout<<"\nPass";
else if(sum<50) cout<<"\nFail ";
}
flag = 1;
break;
}
}
}
if(flag==-1)
cout<<"\nNo Std found with No : "<>StdNo;
int flag = -1;
ifstream file(stdsRec);
string str;
int StdFound = 0;
while (getline(file, str))
{
if(str.length()>0){
char temp[1000];
memset(temp,1000,sizeof(temp));
strcpy(temp, str.c_str());
char * ptr;
ptr = strtok(temp ,"|");
int tempno = atoi(ptr);
if(StdNo == tempno )
{
addStdRecord(tempFile);
StdFound = 1;
}
else{
ofstream file(tempFile, ios_base::app);
file<>moduleNo;
int flag = -1;
ifstream file(modulesRecord);
string str;
while (getline(file, str))
{
if(str.length()>0){
char temp[1000];
memset(temp,1000,sizeof(temp));
strcpy(temp, str.c_str());
char * ptr;
ptr = strtok(temp ,"|");
int tempno = atoi(ptr);
cout<<"\nModule no is : "<0)
cout<<"\n"<>moduleNo;
}
//add new module to DB
int addModule(char *modulerecord){
int moduleNo;
char title[50];
char level[50];
ofstream out(modulerecord, ios_base::app);
cout<<"\n# Add New Module #";
cout<<"\nEnter Module No : ";
cin>>moduleNo;
out<>title;
out<>level;
out<>moduleNo;
int flag = -1;
ifstream file(modulesRecord);
string str;
int moduleFound = 0;
while (getline(file, str))
{
if(str.length()>0){
char temp[1000];
memset(temp,1000,sizeof(temp));
strcpy(temp, str.c_str());
char * ptr;
ptr = strtok(temp ,"|");
int tempno = atoi(ptr);
if(moduleNo == tempno )
{
addModule(tempFile);
moduleFound = 1;
}
else{
ofstream file(tempFile, ios_base::app);
file< Add Record";
cout<<"\n2> Update Record";
cout<<"\n3> Get any record";
cout<<"\n4> Get all record";
cout<<"\n5> Add Module";
cout<<"\n6> Get Any Module details";
cout<<"\n7> Get All Modules details";
cout<<"\n8> Update Module";
cout<<"\n9> Find Std Marks";
cout<<"\n0> Exit..";
cout<<"\n Enter your choice : ";
cin>>choice;
switch(choice){
case 1:
stdObj.addStdRecord(stdsRec);
break;
case 2:
stdObj.updateStd();
break;
case 3:
stdObj.displayStdRecord();
break;
case 4:
stdObj.displayAllStdRecord();
break;
case 5:
modObject.addModule(modulesRecord);
break;
case 6:
modObject.displayAnyModuleInfo();
break;
case 7:
modObject.displayAllModulesInfo();
break;
case 8:
modObject.updateModule();
break;
case 9:
stdObj.findStdMarks();
break;
case 0:
cout<<"\nThankyou !! Good Bye\n ";
break;
default:
cout<<"\nInvalid choice..";
getchar();
}
}
return 0;
}