c++ program Projects Students are required to show OOP concepts while exercising the following projects. Students are
Posted: Fri Jul 01, 2022 5:52 am
c++ program ProjectsStudents are required to show OOP concepts while exercising thefollowing projects. Students are supposed to implement as many asthey can the concepts of OOP.
Student Information SystemThis is also a simple project, make person as the base class,teacher and student should be its derived classes. Project shouldimplement which course student has taken from which teacher andwhat were the grades of student in that subject.
having introduction, class diagram and the implementation(code). create student. txt file like this where's student informationstore.
and create multiple classes like this. also createnteacher class.
improve this program...
#include<iostream>#include<fstream>#include<iomanip>
using namespace std;int main() { FILE *fp, *ft; char another, choice;
struct student { char first_name[50],last_name[50]; char course[100]; int section; };
struct student e; char xfirst_name[50], xlast_name[50]; long int recsize;
fp=fopen("student.txt","rb+");
if (fp == NULL) { fp = fopen("student.txt","wb+");
if (fp==NULL) { puts("Cannot openfile"); return 0; } }
recsize = sizeof(e);
while(1) { system("cls");
cout << "\t\t====== STUDENTINFORMATION SYSTEM ======"; cout <<"\n\n "; cout << "\n\n"; cout << "\n \t\t\t 1. Add Records"; cout << "\n \t\t\t 2. List Records"; cout << "\n \t\t\t 3. ModifyRecords"; cout << "\n \t\t\t 4. DeleteRecords"; cout << "\n \t\t\t 5. Exit Program"; cout << "\n\n"; cout << "\t\t\t Select Your Choice :=>"; fflush(stdin); choice = getche(); switch(choice) { case '1' : fseek(fp,0,SEEK_END); another ='Y'; while(another == 'Y' ||another == 'y') { system("cls"); cout<< "Enter the Firt Name : "; cin>> e.first_name; cout<< "Enter the Last Name : "; cin>> e.last_name; cout<< "Enter the Course : "; cin>> e.course; cout<< "Enter the Section : "; cin>> e.section; fwrite(&e,recsize,1,fp); cout<< "\n Add Another Record (Y/N) "; fflush(stdin); another =getchar(); } break; case '2': system("cls"); rewind(fp); cout << "=== Viewthe Records in the Database ==="; cout << "\n"; while(fread(&e,recsize,1,fp) == 1){ cout << "\n"; cout <<"\n" <<e.first_name << setw(10) << e.last_name; cout << "\n"; cout <<"\n"<<e.course << setw(8) <<e.section; } cout <<"\n\n"; system("pause"); break;
case '3' : system("cls"); another = 'Y'; while (another == 'Y'|| another== 'y') { cout << "\nEnter the last name of the student : "; cin >>xlast_name;
rewind(fp); while(fread(&e,recsize,1,fp) == 1) { if(strcmp(e.last_name,xlast_name) == 0) { cout<< "Enter new the Firt Name : "; cin>> e.first_name; cout<< "Enter new the Last Name : "; cin>> e.last_name; cout<< "Enter new the Course : "; cin>> e.course; cout<< "Enter new the Section : "; cin>> e.section; fseek(fp, -recsize, SEEK_CUR); fwrite(&e,recsize,1,fp); break; } else cout<<"record not found"; } cout << "\n ModifyAnother Record (Y/N) "; fflush(stdin); another =getchar(); } break;
case '4': system("cls"); another = 'Y'; while (another == 'Y'|| another== 'y') { cout << "\nEnter the last name of the student to delete : "; cin >>xlast_name;
ft =fopen("temp.dat", "wb");
rewind(fp); while (fread(&e, recsize,1,fp) == 1)
if(strcmp(e.last_name,xlast_name) != 0) { fwrite(&e,recsize,1,ft); } fclose(fp); fclose(ft); remove("student.txt"); rename("temp.dat","users.txt");
fp=fopen("student.txt","rb+");
cout<< "\n Delete Another Record (Y/N) "; fflush(stdin); another =getchar(); }
break;
case '5': fclose(fp); cout <<"\n\n"; cout <<"\t\t THANK YOU FOR USING THIS SOFTWARE"; cout <<"\n\n"; exit(0); } }
system("pause");return 0;}
Address Course Course Emain PhoneNumber PhoneNumber Student 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM C Header File C++ Source File C Header File C++ Source File C++ Source File C Header File C Header File 1 KB 1 KB 1 KB 1 KB 0 KB 1 KB 1 KB
Student Information SystemThis is also a simple project, make person as the base class,teacher and student should be its derived classes. Project shouldimplement which course student has taken from which teacher andwhat were the grades of student in that subject.
having introduction, class diagram and the implementation(code). create student. txt file like this where's student informationstore.
and create multiple classes like this. also createnteacher class.
improve this program...
#include<iostream>#include<fstream>#include<iomanip>
using namespace std;int main() { FILE *fp, *ft; char another, choice;
struct student { char first_name[50],last_name[50]; char course[100]; int section; };
struct student e; char xfirst_name[50], xlast_name[50]; long int recsize;
fp=fopen("student.txt","rb+");
if (fp == NULL) { fp = fopen("student.txt","wb+");
if (fp==NULL) { puts("Cannot openfile"); return 0; } }
recsize = sizeof(e);
while(1) { system("cls");
cout << "\t\t====== STUDENTINFORMATION SYSTEM ======"; cout <<"\n\n "; cout << "\n\n"; cout << "\n \t\t\t 1. Add Records"; cout << "\n \t\t\t 2. List Records"; cout << "\n \t\t\t 3. ModifyRecords"; cout << "\n \t\t\t 4. DeleteRecords"; cout << "\n \t\t\t 5. Exit Program"; cout << "\n\n"; cout << "\t\t\t Select Your Choice :=>"; fflush(stdin); choice = getche(); switch(choice) { case '1' : fseek(fp,0,SEEK_END); another ='Y'; while(another == 'Y' ||another == 'y') { system("cls"); cout<< "Enter the Firt Name : "; cin>> e.first_name; cout<< "Enter the Last Name : "; cin>> e.last_name; cout<< "Enter the Course : "; cin>> e.course; cout<< "Enter the Section : "; cin>> e.section; fwrite(&e,recsize,1,fp); cout<< "\n Add Another Record (Y/N) "; fflush(stdin); another =getchar(); } break; case '2': system("cls"); rewind(fp); cout << "=== Viewthe Records in the Database ==="; cout << "\n"; while(fread(&e,recsize,1,fp) == 1){ cout << "\n"; cout <<"\n" <<e.first_name << setw(10) << e.last_name; cout << "\n"; cout <<"\n"<<e.course << setw(8) <<e.section; } cout <<"\n\n"; system("pause"); break;
case '3' : system("cls"); another = 'Y'; while (another == 'Y'|| another== 'y') { cout << "\nEnter the last name of the student : "; cin >>xlast_name;
rewind(fp); while(fread(&e,recsize,1,fp) == 1) { if(strcmp(e.last_name,xlast_name) == 0) { cout<< "Enter new the Firt Name : "; cin>> e.first_name; cout<< "Enter new the Last Name : "; cin>> e.last_name; cout<< "Enter new the Course : "; cin>> e.course; cout<< "Enter new the Section : "; cin>> e.section; fseek(fp, -recsize, SEEK_CUR); fwrite(&e,recsize,1,fp); break; } else cout<<"record not found"; } cout << "\n ModifyAnother Record (Y/N) "; fflush(stdin); another =getchar(); } break;
case '4': system("cls"); another = 'Y'; while (another == 'Y'|| another== 'y') { cout << "\nEnter the last name of the student to delete : "; cin >>xlast_name;
ft =fopen("temp.dat", "wb");
rewind(fp); while (fread(&e, recsize,1,fp) == 1)
if(strcmp(e.last_name,xlast_name) != 0) { fwrite(&e,recsize,1,ft); } fclose(fp); fclose(ft); remove("student.txt"); rename("temp.dat","users.txt");
fp=fopen("student.txt","rb+");
cout<< "\n Delete Another Record (Y/N) "; fflush(stdin); another =getchar(); }
break;
case '5': fclose(fp); cout <<"\n\n"; cout <<"\t\t THANK YOU FOR USING THIS SOFTWARE"; cout <<"\n\n"; exit(0); } }
system("pause");return 0;}
Address Course Course Emain PhoneNumber PhoneNumber Student 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM 10-Apr-22 11:54 AM C Header File C++ Source File C Header File C++ Source File C++ Source File C Header File C Header File 1 KB 1 KB 1 KB 1 KB 0 KB 1 KB 1 KB