课程设计 C语言学籍管理系统!!!

用数据文件存放学生的学籍,可对学生学籍进行注册,登录,修改,删除,查找,统计,学籍变化等操作。(用文件保存)功能要求:(1)系统以菜单方式工作。(2)登记学生的学号,姓名... 用数据文件存放学生的学籍,可对学生学籍进行注册,登录,修改,删除,查找,统计,学籍变化等操作。(用文件保存)
功能要求:
(1) 系统以菜单方式工作。
(2) 登记学生的学号,姓名,性别,年龄,籍贯,系别,专业,班级;修改已知学号的学生信息;
(3) 删除已知学号的学生信息;
(4) 查找已知学号的学生信息;
(5) 按学号,专业输出学生籍贯表。
(6) 查询学生学籍变化,比如入学,转专业,退学,降级,休学,毕业。
展开
 我来答
百度网友439f3ac63
2013-10-04 · TA获得超过252个赞
知道小有建树答主
回答量:348
采纳率:0%
帮助的人:64.2万
展开全部
给你看个我写的班费管理系统,跟你这个比较类似,你改下就好了

#include<iostream>
#include<string>
#include<vector>
#include <fstream>
#include<sstream>

using namespace std;

class student
{
public:
student(string ,string ,string ,string );
string getSex(){return _sex;};
string getName(){return _name;};
string getID(){return _id;};
string getmoney(){return _money;};
void setMoney(string a){_money=a;};
void deleted(){_id="deleted";_name="deleted";_sex="deleted";_money="deleted";};
void setName(string);
void save();
void print();
private:
string _id;
string _name;
string _sex;
string _money;
string _total;
};

student::student(string id, string name, string sex,string money)
{
_id=id;_name=name;_sex=sex;
_money=money;
}

void student::save()
{
ofstream outf;
outf.open("myfile.txt",ios::app);
outf<<_id
<<"\t"<< _name
<<"\t"<<_sex
<<"\t"<<_money<<endl;
outf.close();
}

void student::print()
{
cout<<_id
<<"\t\t"<< _name
<<"\t\t"<<_sex
<<"\t\t"<<_money<<endl;
}

void printMenu(void)
{

cout<<"-------------class fee management system--------------"<<endl;
cout<<"| |"<<endl;
cout<<"| author:XY |"<<endl;
cout<<"| www.hdxuyi.cn |"<<endl;
cout<<"|----------------------------------------------------|"<<endl;
cout<<"| |"<<endl;
cout<<"| 1.Increase the student records |"<<endl;
cout<<"| 2.Delete student records |"<<endl;
cout<<"| 3.The total of class fee |"<<endl;
cout<<"| 4.search the class fee |"<<endl;
cout<<"| 5.view all class fee |"<<endl;
cout<<"| 6.add one class fee |"<<endl;
cout<<"| 0.exit |"<<endl;
cout<<"| |"<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"make your choice:"<<endl;
}

void addstudent();//添加学生信息
void delstudent();//删除学生信息
void selstudent();//查询学生信息
void selall();//查询所有信息
void total();//班费总额
void addmoney();//增加某个学生的班费(实为更新操作)

bool isinfile=false;//判断是否读取过txt
vector<student> stu;//全局对象student
int main()
{
int order=0;
printMenu();
cin>>order;
while(order!=0)
{
switch(order)
{
case 1:addstudent();printMenu();cin>>order;break;
case 2:delstudent();printMenu();cin>>order;break;
case 3:total();printMenu();cin>>order;break;
case 4:selstudent();printMenu();cin>>order;break;
case 5:selall();printMenu();cin>>order;break;
case 6:addmoney();printMenu();cin>>order;break;
default:break;
}
}
cout<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"thank you for using the system~"<<endl;
cout<<"------------------------------------------------------"<<endl;
}

void infile()//读取txt
{
if (isinfile==false)
{
stu.clear();
string tmp_id,tmp_name,tmp_sex,tmp_money;
int time =0;
string lines,field;

ifstream infile("myfile.txt");

while (getline (infile, lines))
{
istringstream stream(lines);
while(stream>>field)
{
switch(time)
{
case 0:tmp_id = field;time=1;break;
case 1:tmp_name = field;time=2;break;
case 2:tmp_sex = field;time=3;break;
case 3:tmp_money = field;time=0;
stu.push_back(student(tmp_id,tmp_name,tmp_sex,tmp_money));break;
}
}
}
isinfile==true;
infile.close();
}
}

void addstudent()
{
string tmp_id;
string tmp_name;
string tmp_sex;
string tmp_money;
cout<<"Insert-->ID:";
cin>>tmp_id;
cout<<"Insert-->Name:";
cin>>tmp_name;
cout<<"Insert-->Sex:";
cin>>tmp_sex;
cout<<"Insert-->Money:";
cin>>tmp_money;
student(tmp_id,tmp_name,tmp_sex,tmp_money).save();
cout<<"save success!"<<endl;
isinfile=false;
}

void selall()
{
infile();
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<endl;
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
(*iter).print();
}
cout<<"------------------------------------------------------"<<endl;
}
cout<<endl;
}

void delstudent()
{
infile();
string search_name;
string search_id;
cout<<"delete---->id:"<<endl;
cin>>search_id;
cout<<"delete---->name:"<<endl;
cin>>search_name;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search_name&&(*iter).getID()==search_id)
{
isFind=true;
stu.erase(iter);
}
}

//重新将删除后的集合写入txt
vector<student>::iterator iter1=stu.begin();
vector<student>::iterator iter1_end=stu.end();
ofstream outf;
outf.open("myfile.txt");
for(;iter1!=iter1_end;iter1++)
{
outf<<(*iter1).getID()
<<"\t"<<(*iter1).getName()
<<"\t"<<(*iter1).getSex()
<<"\t"<<(*iter1).getmoney()<<endl;
}
outf.close();
cout<<"delete success!"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}

void total()
{
infile();
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
(*iter).print();
}
cout<<"------------------------------------------------------"<<endl;
}
cout<<endl;
}

void selstudent()
{
infile();
string search;
cout<<"search---->id or name:"<<endl;
cin>>search;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"------------------------------------------------------"<<endl;
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search||(*iter).getID()==search)
{
isFind=true;
(*iter).print();
}
}
cout<<"------------------------------------------------------"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}

void addmoney()
{
infile();
string search;
string update;
cout<<"search---->id or name:"<<endl;
cin>>search;
bool isFind=false;
if (stu.size()==0)
{
cout<<"ERR:---->No data in the system!"<<endl;
}
else
{
vector<student>::iterator iter=stu.begin();
vector<student>::iterator iter_end=stu.end();
cout<<"id name sex money"<<endl;
for(;iter!=iter_end;iter++)
{
if( (*iter).getName()==search||(*iter).getID()==search)
{
(*iter).print();
isFind=true;
cout<<"update---->new class fee:"<<endl;
cin>>update;
(*iter).setMoney(update);
}
}

//重新将修改后的集合写入txt
vector<student>::iterator iter1=stu.begin();
vector<student>::iterator iter1_end=stu.end();
ofstream outf;
outf.open("myfile.txt");
for(;iter1!=iter1_end;iter1++)
{
outf<<(*iter1).getID()
<<"\t"<<(*iter1).getName()
<<"\t"<<(*iter1).getSex()
<<"\t"<<(*iter1).getmoney()<<endl;
}
outf.close();
cout<<"update success!"<<endl;
}
if(!isFind)
{
cout<<"Can't find this student!"<<endl;
}
cout<<endl;
}
佳西夜
2013-10-04 · TA获得超过265个赞
知道小有建树答主
回答量:369
采纳率:0%
帮助的人:172万
展开全部

这个基本满足你要求吧,你自己看看

本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wansong
2013-10-04 · 贡献了超过134个回答
知道答主
回答量:134
采纳率:0%
帮助的人:30万
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式