C++ curriculum design – student achievement management system

Although old, but very classic, so I put their own code on top, may be able to see the original naive

Code download address at the end of the article, students who need to take.

The course design consists of two modules:

  • Teacher authority module
  • Student Authority module

The student Permissions module contains:

1. Add 2. Display 3. Add 4

The teacher permission module contains:

1. Add 2. Display 3. Add 4. Find 5

Main knowledge used:

(1) class (2) inheritance (3) struct (4) loop (5) array (6) function

Main line of each functional module:

  • Enter the password to enter the menu interface with different permissions
  • Enter the menu interface, make different choices, call relevant functions, enter different function modules
  • Carry on different function module, carry on the operation, realize the corresponding function
  • Log out

Disadvantages:

  • Some student information must be entered before various operations can be carried out
  • No file added, save student information to file
  • Can not dynamically implement the input of student information, waste memory space

** [article benefits] : ** Xiaobian recommend their own C language communication group: 967051845! Sorted out some personal feel better learning books, video material sharing in the group file inside, there is a need to add oh! ~

The code is as follows:

<strong>#include<iostream>
#include<cstring>
#include<string>
#include<fstream>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<conio.h>
#include<windows.h>
using namespace std;
class student
{
private:
	long long  num;
	char name[20];
	char sex[6];
	int age;
	char  phone[20];
public:
	static int NUM;
	student{} ~ ()student() {}
	void input();
	friend void readin();
	friend   void show();
	friend   void mood();
	friend  void del();
	friend  void soort();
	friend   void save();
	friend  void findyou();
	friend void clear1();
} zhuo_yue[100];
int student::NUM=0;
void readin()
{
	ifstream in("inf.txt",ios::binary);
	int i=1;
	while(! in.eof()) { in.read((char*) &zhuo_yue[i],sizeof(zhuo_yue[i])); i++; } in.close(); student::NUM=i-2; } voidshow()
{
	if(student::NUM==0)
		cout<<endl<<endl<<setw(10)<<"No student information at present";
	else
	{
		cout<<"Student Information Display"<<endl<<endl;
		cout<<"Student id"<<setw(15)<<"Name"<<setw(15)
			<<"Gender"<<setw(15)<<"Age"<<setw(15)<<"Telephone"
			<<endl;
		for(int i=1; i<=student::NUM; i++)
		{
			cout<<zhuo_yue[i].num<<setw(15)<<zhuo_yue[i].name<<setw(15)
				<<zhuo_yue[i].sex<<setw(15)<<zhuo_yue[i].age<<setw(15)<<zhuo_yue[i].phone
				<<endl;
		}
	}
	cout<<endl<<setw(40)<<"Press any key to exit";
	getch();
}
void mood()
{
	long long L;
	cout<<Please enter the student ID you want to change:;
	cin>>L;
	cout<<endl<<setw(40)<<"Confirm modification (Y /n)";
	if(getch()=='y')
	{
		system("cls");
		for(int i=1; i<=student::NUM; i++)
			if(L==zhuo_yue[i].num)
			{
				cout<<"Student Information modification"<<endl<<endl;
				cout<<"Student number.";
				cin>>zhuo_yue[i].num;
				cout<<endl<<endl;
				cout<<"Name:";
				cin>>zhuo_yue[i].name;
				cout<<endl<<endl;
				cout<<"Gender.";
				cin>>zhuo_yue[i].sex;
				cout<<endl<<endl;
				cout<<"Age.";
				cin>>zhuo_yue[i].age;
				cout<<endl<<endl;
				cout<<"Phone.";
				cin>>zhuo_yue[i].phone;
				cout<<endl<<endl;
				break;
			}
		cout<<endl<<setw(40)<<"Modified. Press any key to exit.";
		getch();
	}
	else
		return;
}
void del()
{
	int sum=0;
	cout<<setw(50)<<[1] Delete by student NUMBER [2] Delete by name<<endl;
	if(getch()=='1')
	{
		cout<<Please enter your student number:;
		long long it;
		cin>>it;
		cout<<endl<<setw(30)<<"Are you sure to delete this student? (y/n)";
		if(getch()=='y')
		{
			system("cls");
			for(int i=1; i<=student::NUM; i++)
			{
				if(zhuo_yue[i].num==it)
				{
					for(int j=i+1; j<=student::NUM; j++)
						zhuo_yue[j-1]=zhuo_yue[j];
					student::NUM--;
					sum++;
					break;
				}
			}
			cout<<"Delete all"<<sum<<"People";
		}
		else
			return;
	}
	else  if(getch()=='2')
	{
		char name1[20];
		cout<<"Please enter name:";
		cin>>name1;
		cout<<endl<<setw(30)<<"Are you sure to delete this student? (y/n)";
		if(getch()=='y')
		{
			system("cls");
			for(int i=1; i<=student::NUM; i++)
			{
				if(strcmp(zhuo_yue[i].name,name1)==0)
				{
					for(int j=i+1; j<=student::NUM; j++)
						zhuo_yue[j-1]=zhuo_yue[j];
					student::NUM--;
					sum++;
				}
			}
			cout<<"Delete all"<<sum<<"People";
		}
		else
			return;
	}
	cout<<endl<<endl<<setw(40)<<"Press any key to end.";
	getch();
}
void soort()
{
	cout<<setw(50)<<"[1] Sort by student number [2] Sort by age"<<endl;
	if(getch()=='1')
	{
		for(int i=1; i<student::NUM; i++)
			for(int j=1; j<student::NUM-i+1; j++)
			{
				if(zhuo_yue[j].num>zhuo_yue[j+1].num)
				{
					student it=zhuo_yue[j];
					zhuo_yue[j]=zhuo_yue[j+1];
					zhuo_yue[j+1]=it;
				}
			}
		cout<<endl<<setw(50)<<"Sorted, press any key to exit";
		getch();
	}
	else  if(getch()=='2')
	{
		for(int i=1; i<student::NUM; i++)
			for(int j=1; j<student::NUM-i+1; j++)
			{
				if(zhuo_yue[j].age>zhuo_yue[j+1].age)
				{
					student it=zhuo_yue[j];
					zhuo_yue[j]=zhuo_yue[j+1];
					zhuo_yue[j+1]=it;
				}
			}
		cout<<endl<<setw(50)<<"Sorted, press any key to exit";
		getch();
	}
}
void student::input()
{
LI:
	NUM++;
	cout<<Student Information Input<<endl<<endl;
	cout<<"Student number.";
	cin>>zhuo_yue[NUM].num;
	cout<<endl<<endl;
	cout<<"Name:";
	cin>>zhuo_yue[NUM].name;
	cout<<endl<<endl;
	cout<<"Gender.";
	cin>>zhuo_yue[NUM].sex;
	cout<<endl<<endl;
	cout<<"Age.";
	cin>>zhuo_yue[NUM].age;
	cout<<endl<<endl;
	cout<<"Phone.";
	cin>>zhuo_yue[NUM].phone;
	cout<<endl<<endl;
	cout<<"Entered, continue (y/n)";
	if(getch()=='y')
	{
		system("cls");
		goto LI;
	}
	else return;
}
void save()
{
	ofstream out("inf.txt",ios::binary);
	cout<<endl<<setw(40)<<"Saved. Press any key to exit.";
	for(int i=1; i<=student::NUM; i++)
	{
		out.write((char*)&zhuo_yue[i],sizeof(zhuo_yue[i]));
	}
	out.close();
	getch();
}
void findyou()
{
	int sum=0;
	cout<<setw(50)<<[1] Search by student number [2] Search by name<<endl;
	if(getch()=='1')
	{
		cout<<Please enter your student number:;
		long long it;
		cin>>it;
		cout<<endl<<setw(30)<<"Are you sure you want to see this student? (y/n)";
		if(getch()=='y')
		{
			system("cls");
			cout<<"View student information"<<endl<<endl;
			for(int i=1; i<=student::NUM; i++)
			{
				if(zhuo_yue[i].num==it)
				{
					cout<<setw(20)<<"Student number."<<zhuo_yue[i].num<<endl
						<<setw(20)<<"Name:"<<zhuo_yue[i].name<<endl
						<<setw(20)<<"Gender."<<zhuo_yue[i].sex<<endl
						<<setw(20)<<"Age."<<zhuo_yue[i].age<<endl
						<<setw(20)<<"Phone."<<zhuo_yue[i].phone<<endl;
					cout<<"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -"<<endl<<endl;
					sum++;
				}
			}
			cout<<"Co-display"<<sum<<"People";
		}
		else
			return;
	}
	else  if(getch()=='2')
	{
		char name1[20];
		cout<<"Please enter name:";
		cin>>name1;
		cout<<endl<<setw(30)<<"Are you sure you want to see a student with this name? (y/n)";
		if(getch()=='y')
		{
			system("cls");
			cout<<"View student information"<<endl<<endl;
			for(int i=1; i<=student::NUM; i++)
			{
				if(strcmp(zhuo_yue[i].name,name1)==0)
				{
					cout<<setw(20)<<"Student number."<<zhuo_yue[i].num<<endl
						<<setw(20)<<"Name:"<<zhuo_yue[i].name<<endl
						<<setw(20)<<"Gender."<<zhuo_yue[i].sex<<endl
						<<setw(20)<<"Age."<<zhuo_yue[i].age<<endl
						<<setw(20)<<"Phone."<<zhuo_yue[i].phone<<endl;
					cout<<"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -"<<endl<<endl;
					sum++;
				}
			}
			cout<<"Co-display"<<sum<<"People";
		}
		else
			return;
	}
	cout<<endl<<endl<<setw(40)<<"Press any key to end.";
	getch();
}
char mainmenu()
{
	cout<<"\n\n Welcome to student Information Management System"<<endl<<endl;
	cout<<"\n\n [1] Administrator [2] Student"<<endl<<endl;
	char ff=getch();
	return ff;
}
void adminmainmenu()
{
	cout<<"\n\n Welcome to the Student Information Management System (Administrator)"<<endl<<endl
		<<endl
		<<endl
		<<"1: Input student information"<<endl<<endl
		<<"2: Display student information"<<endl<<endl
		<<"3: Modify student information"<<endl<<endl
		<<"4: Delete student information"<<endl<<endl
		<<"5: Finding student Information"<<endl<<endl
		<<"6: Save student information"<<endl<<endl
		<<"7: Sort student information"<<endl<<endl
		<<"8: Return to initial page"<<endl<<endl
		<<"0: Exit system"<<endl;
}
void mainmenu1()
{
	cout<<"\n\n Welcome to student Information Management System (Student)"<<endl<<endl
		<<endl
		<<endl
		<<"1: Display student information"<<endl<<endl
		<<"2: Finding student Information"<<endl<<endl
		<<"3: Sort student information"<<endl<<endl
		<<"4: Return to initial page"<<endl<<endl
		<<"0: Exit system"<<endl;
}
void clear1()
{
	fstream cl;
	cl.open("inf.txt",ios::out);
	cl.close();
	cout<<"Destroyed successfully.";
	exit(1);
}
int main()
{
LIIIII:
	readin();
	system("cls");
	char get =  mainmenu();
	if(get=='1')
	{
		char adminname[20],mima[20];
		ifstream in;
		ofstream out;
		in.open("admin.txt",ios::in);
		if(!in)
		{
			cout<<"No administrator account, please set:"<<endl<<endl;
FF:
			cout<<"Enter account name:";
			cin>>adminname;
			cout<<"Enter password:";
			cin>>mima;
			cout<<"Sure to create (y/n)";
			char fff=getch();
			if(fff=='y')
			{
				out.open("admin.txt",ios::app);
				out<<adminname<<' '<<mima<<' ';
				system("cls");
				cout<<"Created. Press any key to return.";
				getch();
				out.close();
				goto LIIIII;
			}
			else if(fff=='n')
				goto LIIIII;
		}
		else
		{
			system("cls");
			cout<<"Existing user"<<endl<<endl;
			cout<<Create an administrator account (Y/N);
			char gr=getch();
			if(gr=='y')
			{
				system("cls");
				goto FF;
			}
ss1:
			system("cls");
			cout<<"Login Account:";
			cin>>adminname;
			cout<<"Enter password:";
			cin>>mima;
			char adminname1[20],mima1[20];
			int flog=0;
			while(! in.eof()) {in>>adminname1>>mima1;
				if(! strcmp(adminname,adminname1)&&! strcmp(mima1,mima)) { flog=0;break; }}if(flog==0)
			{
				system("cls");
				cout<<"Login successful press any key to continue.";
				getch();
			}
			else
			{
				cout<<"Password error"<<endl<<endl;
				cout<<"[1] Return to initial screen [2] Re-enter password";
				char gg=getch();
				if(gg=='1')
					goto LIIIII;
				else
				{
					system("cls"); goto ss1; }}}while(1)
		{
			adminmainmenu();
			char ch;
			ch=getchar();
			system("CLS");
			switch(ch)
			{
			case '1':
				zhuo_yue[student::NUM].input();
				break;
			case '2':
				show();
				break;
			case '3':
				mood();
				break;
			case '4':
				del();
				break;
			case '5':
				findyou();
				break;
			case '6':
				save();
				break;
			case '7':
				soort();
				break;
			case '8':
				goto LIIIII;
			case 'F':
				clear1();
			case '0':
				cout<<"\n\n\n\n thank you for using ~~";
				exit(1); }}}else if(get=='2')
	{
		char stuname[20],stumima[20];
		ifstream in;
		ofstream out;
		in.open("student.txt",ios::in);
		if(!in)
		{
			cout<<"No student account, please set:"<<endl<<endl;
LL:
			cout<<"Enter account name:";
			cin>>stuname;
			cout<<"Enter password:";
			cin>>stumima;
			cout<<"Sure to create (y/n)";
			char fff=getch();
			if(fff=='y')
			{
				out.open("student.txt",ios::app);
				out<<stuname<<' '<<stumima<<' ';
				system("cls");
				cout<<"Created. Press any key to return.";
				getch();
				out.close();
				goto LIIIII;
			}
			else if(fff=='n')
				goto LIIIII;
		}
		else
		{
			system("cls");
			cout<<"Existing user"<<endl<<endl;
			cout<<Whether to create an account (y/n);
			char gr=getch();
			if(gr=='y')
			{
				system("cls");
				goto LL;
			}
sss:
			system("cls");
			cout<<"Login Account:";
			cin>>stuname;
			cout<<"Enter password:";
			cin>>stumima;
			char stuname1[20],stumima1[20];
			int flog=1;
			while(! in.eof()) {in>>stuname1>>stumima1;
				if(! strcmp(stuname,stuname1)&&! strcmp(stumima1,stumima)) { flog=0;break; }}if(flog==0)
			{
				system("cls");
				cout<<"Login successful press any key to continue.";
				getch();
			}
			else if(flog==1)
			{
				system("cls");
				cout<<"Password error"<<endl<<endl;
				cout<<"[1] Return to initial screen [2] Re-enter password";
				char gg=getch();
				if(gg=='1')
					goto LIIIII;
				else
				{
					system("cls");
					goto  sss;
				}
			}
			in.close();
		}
		while(1)
		{
			mainmenu1();
			char ch;
			ch=getchar();
			system("CLS");
			switch(ch)
			{
			case '1':
				show();
				break;
			case '2':
				findyou();
				break;
			case '3':
				soort();
				break;
			case 'F':
				clear1();
			case '4':
				goto LIIIII;
			case '0':
				cout<<"\n\n\n\n thank you for using ~~";
				exit(1);
			}
		}
	}
}
</strong>
Copy the code

welfare

Finally, if you feel that learning materials are difficult to find, you can add small SERIES of C language /C++ communication group: 967051845! Learning materials have been shared in the group, looking forward to your joining ~