Student Performance Management System

Source: Internet
Author: User

#include <iostream> #include <string> #include <fstream> #include <cstdlib>using namespace std; enum {subject=5};//altogether five-door typedef struct{char subject[10];//account name int score;//account score}markinfo;typedef struct studentnode{ Markinfo mark[subject];int Totalmark;char name[10];//student name Studentnode * NEXT;} Studentnode;class Student {Studentnode * head;public:student (); int addstudent (); ~student (); int countmark (); int Sortbymark (); int save (); int show (); int display (); int readfiletolist (); int searchbyname ();}; Student::student ()//is initialized with a constructor function.

{head=new studentnode;head->next=null;} 1. Enter the student's name, score and other data, and save in the linked list. int student::addstudent () {Studentnode * p;int I;char check;system ("CLS");cout<< "**********************" < <endl;cout<< "Please enter student information:" <<endl;do{p=new studentnode;cin.ignore ();cout<< "name:"; Gets (p->name );i=0;p->totalmark=0;do{cout<< "Subject:", gets (P->mark[i].subject);cout<< "Score (0--100):";d o{cin> >p->mark[i].score;} while (p->mark[i].score>100| | p->mark[i].score<0);p->totalmark=p->totalmark+p->mark[i].score;getchar ();} while (++i!=subject); if (head->next==null) {head->next=p;p->next=null;} else {p->next=head->next;head->next=p;} cout<< "continue to join? Y or N:"; Check=getchar ();} while (check!= ' n ' &&check!= ' n '); return 0;} 2. Calculate the total of each student. int Student::countmark () {Studentnode * p=head->next;if (p==null) {cout<< "No students, please enter again" <<endl;system (" Pause "); return 0;} else {cout<< "***************" <<endl;cout<< "Student score Summary:" <<endl;while (p) {cout<< "name:" <<p->name<< "total:" <<p->totalmark<<endl;p=p->next;}} System ("pause"); return 0;} 4. Output all student scores into a file. int Student::save () {char address[35];int i;studentnode * p=head->next;cout<< "Please enter a saved address" <<endl; Cin.ignore (); Gets (address); Ofstream Fout;fout.open (Address,ios::app|ios::out); while (p) {fout<< "*";fout<<p-> name<< "*"; I=0;while (I!=subject) {fout<<p->mark[i].subject<< "*"; Fout<<p->mark[i]. score;i++;} fout<< "*";p =p->next;} Fout.flush (); Fout.close ();cout<< "has been saved. Please refer to "; system" ("pause"); return 0;} Student::~student ()//destructor {Studentnode * p,* S;p=head->next;while (p) {S=p->next;delete p;p=s;} Delete Head;} 3. Sort records According to their total size int Student::sortbymark () {Studentnode *move1=head->next;studentnode *move2,*max,*pre1,*pre2,* Maxpre,*s=move1;if (head->next==null) {cout<< "no record, please join" <<endl;system ("pause"); return 0;} for (pre1=head,max=move1,maxpre=pre1;move1->next!=null;pre1=move1, maxpre=pre1,move1=move1->next,max=move1) {for (pre2=move1,move2=move1->next;move2!=null;pre2=move2,move2= Move2->next) if (Move2->totalmark>max->totalmark) {maxpre=pre2;max=move2;} if (Move1->next==max)//Exchange Max and move1.

{Pre1->next=max;move1->next=max->next;max->next=move1;move1=max;} Else{s=move1->next;move1->next=max->next;max->next=s;maxpre->next=move1;pre1->next=max;move1 =max;}} cout<< "has been sorted from large to small" <<endl;system ("pause"); return 0;} 5 output input Information int student::show () {Studentnode * p=head->next;int i;if (head->next==null) {cout<< "No student record, please join" <<endl;system ("pause"); return 0;} else {while (p) {cout<< "name:" <<p->name;i=1;while (i!=subject+1) {cout<< "account:" <<p->mark[ i-1].subject;cout<< "score:" <<p->mark[i-1].score;i++;} Cout<<endl;p=p->next;}} System ("pause"); return 0;} 6: Read record from file int student::d isplay () {ifstream Fin;char buf[100];char str[25];cout<< "Please enter path and file name:" <<endl; Cin.ignore (), gets (str), Fin.open (str), if (!fin) {cout<< "Without this file" <<endl;system ("pause"); return 0;} while (Fin) {fin.getline (buf,sizeof (BUF)); Cout<<buf<<endl;} System ("pause"); return 0;} 8 Read the data from the file and save the data in the linked list int Student::readfilEtolist () {ifstream fin;int i;char str[25];cout<< "Please enter the path and file name:" <<endl;cin.ignore (); gets (str); Fin.open ( STR); if (!fin) {cout<< "does not have this file" <<endl;system ("pause"); return 0;} Studentnode * P;fin.ignore (+, ' * '), while (Fin) {p=new studentnode;p->totalmark=0;fin.getline (p->name,100, ' * ') ); I=0;while (i!=subject) {fin.getline (p->mark[i].subject,100, ' * ');fin>>p->mark[i].score;p-> totalmark+=p->mark[i].score;i++;} if (head->next==null) {head->next=p;p->next=null;} Else{p=head->next;head->next=p;}} cout<< "Information has been saved in the list" <<endl;system ("pause"); return 0;} 9 Find by name int Student::searchbyname () {if (head->next==null) {cout<< "No students, please join or read from the file" <<endl; System ("pause"); return 0;} Studentnode * P=head->next;char findname[10];int i;cout<< "Please enter your name:"; Cin.ignore (); gets (FindName); while (p) {if (!STRCMP (P->name,findname)) {cout<< "is searched. Find the student information such as the following: "<<endl<<endl;cout<<" Name: "<<p->name;i=1;while (i!=subject+1) {cout<<"Subject: "<<p->mark[i-1].subject;cout<<" score: "<<p->mark[i-1].score;i++;} Cout<<endl;system ("pause"); return 1;} P=p->next;} cout<< "Without this student, please join or read from the file" <<endl;system ("pause"); return 0;} int ShowMenu () {int Choice;char * menu[9]={"1: Enter student scores to save to list \ n", "2: Calculate each student's total score \ n", "3: Sort records According to total score", "4: Output all student scores into a file \ n "," 5: Display the newly entered student information \ n "," 6: Read the information from the file \ n "," 7: Save the file information in the list \ n "," 8: Find student record by name \ n "," 9: End program \ n "};cout<<" << "* * * * * * "<<endl;cout<<" * "<<" "<<" Student Performance management System "< < "*" <<endl;cout<< "" << "*****************************************************" <<endl; for (choice=0;choice<9;choice++) cout<< "" <<menu[choice];cout<< "<<" ****************** "<<endl;cout<<" choose to continue "<<endl;do{cin> >choice;} while (choice>9| | CHOICE&LT;1); return choice;} int main () {int menuitem,flag=1;student stu;while (flag) {sYstem ("CLS"); Menuitem=showmenu (); switch (MenuItem) {case 1:{stu.addstudent (); Case 2:{stu.countmark (); Case 3:{stu.sortbymark (); Case 4:{stu.save (); Case 5:{stu.show (); Case 6:{stu.display (); Case 7:{stu.readfiletolist (); Case 8:{stu.searchbyname (); Case 9:{flag=0;break;}}} return 0;


Student Performance Management System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.