Using Namespace STD Class Student
Using Namespace STD Class Student
h> using namespace std; class student{ protected: char name[40]; char roll[10]; char dep[5]; char batch[5]; void get(){ cout<<"\n Enter cin>>name; cout<<"\n Enter cin>>roll; cout<<"\n Enter cin>>dep; cout<<"\n Enter cin>>batch; } };
class cgpa:protected student{ private: char subname[10][20]; char subcode[10][20]; float gpa[10]; float credit[10]; float totalcredit; float subg[10]; float total; int i; float grade; char gradeno[4]; public: void getgpa(); void file(); void gra(float); }; void cgpa::gra(float k){ while(1) { if(k<2.0) { strcpy(gradeno,"F"); break; } else if(k<2.25) {strcpy(gradeno,"D" ); break; } else if(k<2.5) {strcpy(gradeno,"c" ); break;
} else if(k<2.75) {strcpy(gradeno,"c+" ); break; } else if(k<3.0) {strcpy(gradeno,"B-" ); break; } else if(k<3.25) {strcpy(gradeno,"B" ); break; } else if(k<3.5) {strcpy(gradeno,"B+" ); break; } else if(k<3.75) {strcpy(gradeno,"A-" ); break; } else if(k<4.0) {strcpy(gradeno,"A" ); break; } else if(k==4) {strcpy(gradeno,"A+" ); break; } } } void cgpa::getgpa(){get(); totalcredit =0; total=0; cout<<"\n HOW MANY SUBJECTS YOU REGISTERED : "; cin>>i; for(int j=0;j<i;j++) { cout<<"\n Enter the subject name: "; gets(subname[j]); cout<<"\n Enter the subject code: "; gets(subcode[j]); cout<<"\n Enter the credit of that subject : "; cin>>credit[j]; cout<<"\n Enter the GPA of that subject: "; cin>>gpa[j]; totalcredit=totalcredit+credit[j]; subg[j]=gpa[j]*credit[j]; total=subg[j]+total; } grade=total/totalcredit; cout<<"RESULT "<<grade; gra(grade); cout<<"\n***GRADE*** "<<gradeno; getch(); fstream x("***RESULT***",ios::app|ios::out);
x<<endl <<name<<"\t"<<roll<<"\t"<<grade<<"\t"<<gradeno<<endl; x.close(); } void cgpa::file() { getgpa(); ofstream out(roll); out<<"\nName "<<name; out<<"\nRoll "<<roll; out<<"\nDeperment "<<dep; out<<"\n Batch "<<batch; out<<"\n\n\n Subject name\t Subject code\t credit of that subject\tGPA of that Subject"; for(int j=0;j<i;j++) {out<<"\n"; out<<subname[j]; out<<"\t\t\t"<<subcode[j]; out<<"\t\t\t" ; out<<credit[j]; out<<"\t\t\t" ; out<<gpa[j]; } out<<"\n\nTOTAL CREDIT= "<<totalcredit; out<<"\n\nTOTAL GRADE POINT "<<grade; out<<"\n\nCGPA "<<gradeno; out.close(); }
int main() { int p; while(1) { cout<<" press (1) for Input\n "; cout<<" press (2) for confirmation Slip\n "; cout<<" press (3) for search \n"; cout<<" press (4) for exit\n "; cin>>p; if(p==1) {cgpa x; x.file(); } if(p==2) {cout<<"input the roll"; char roll[20]; cin>>roll; char c; ifstream x(roll); while(x) { x.get(c); cout<<c; }
getch(); } if(p==3) { char c; ifstream x("RESULT"); while(x) {x.get(c); cout<<c; } getch(); } if(p==4) break; } return 0; }