下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 学分和绩点计算器

学分和绩点计算器.doc

学分和绩点计算器

yang光武
2017-11-11 0人阅读 举报 0 0 暂无简介

简介:本文档为《学分和绩点计算器doc》,可适用于IT/计算机领域

学分和绩点计算器()输入课程名、学分和成绩通过绩点计算公式计算相应的绩点满足如下要求:根据南京邮电大学的本科生《南京邮电大学学生学籍管理办法》规定:为反映学生学习的质量采用学分绩点制的学习质量评定方法。学生学分绩点以平均学分表示其计算方法如下:绩点(GPA)低于分折合为绩点不及格折合为绩点分折合为绩点及格折合为绩点分折合为绩点中等折合为绩点分折合为绩点良好折合为绩点分折合为绩点优秀折合为绩点。平均学分绩点(GPA)=(课程学分数×绩点数×K)课程学分数平均学分绩点分为学年平均学分绩点和累积平均学分绩点:即按学年结算的平均学分绩点称为学年平均学分绩点从入学后累积结算的平均学分绩点积为累积平均学分绩点。()判断所获得的绩点是否合格能给出相应的结果提示()程序操作友好、界面美观。扩展要求。()从文件中读取课程的学分与成绩并保存绩点计算的结果并根据排序算法排序给出每门课程所获得的绩点。()实现绩点的预警功能。如按照班级(或者专业)的学分统计查询功能从文件读入多个学生的学分绩点按照总的绩点排序。#include<iostream>#include<fstream>#include<sstream>#include<string>#include<iomanip>#include<vector>#include<algorithm>#include<numeric>#include<functional>usingnamespacestdclassCourse{private:intno序号stringyear学年学期intcode课程代码stringname课程名称floatcredit学分intscore成绩stringquality成绩性质stringcourseQua课程性质floatgpa绩点(非绩点和)public:构造与析构及赋值运算符Course(){}Course(intnoV,stringyearV,intcodeV,stringnameV,floatcreditV,intscoreV,stringqualityV,stringcourseQuaV="#"):no(noV),year(yearV),code(codeV),name(nameV),credit(creditV),score(scoreV),quality(qualityV),courseQua(courseQuaV){}Course(constCoursetemp){no=tempnoyear=tempyearcode=tempcodename=tempnametempcreditcredit=score=tempscorequality=tempqualitycourseQua=tempcourseQuagpa=tempgpa}~Course(){}Courseoperator=(constCoursetemp){no=tempnoyear=tempyearcode=tempcodename=tempnamecredit=tempcreditscore=tempscorequality=tempqualitycourseQua=tempcourseQuagpa=tempgpareturn*this}访问器成员函数stringgetYear()const{returnyear}stringgetName()const{returnname}floatgetCredit()const{returncredit}floatgetGpa()const{returngpa}intgetScore()const{returnscore}mutator函数voidset(intnoV,stringyearV,intcodeV,stringnameV,floatqualityV,stringcourseQuaV="#")creditV,intscoreV,string{no=noVyear=yearVcode=codeVname=nameVcredit=creditVscore=scoreVquality=qualityVcourseQua=courseQuaV}voidsetGpa(){if(score<)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=if(score>=score<=)gpa=}voidshow(){cout<<left<<setw()<<year<<setw()<<namecout<<setw()<<credit<<setw()<<scorecout<<setw()<<quality<<setw()<<gpa<<endl}运算符重载booloperator<(constCoursetemp)const{if(score<tempscore)returntrueelsereturnfalse}booloperator>(constCoursetemp)const{if(score>tempscore)returntrueelsereturnfalse}friendclassList}classCourseSigma:publicCourse{private:floatcreditPlusGpapublic:CourseSigma(constCoursetemp):Course(temp),creditPlusGpa(tempgetCredit()*tempgetGpa()){}booloperator<(constCourseSigmatemp)const{returncreditPlusGpa<tempcreditPlusGpatrue:false}booloperator>(constCourseSigmatemp)const{returncreditPlusGpa>tempcreditPlusGpatrue:false}voidshow(){cout<<left<<setw()<<getYear()<<setw()<<getName()cout<<setw()<<getCredit()<<setw()<<getScore()cout<<setw()<<getGpa()<<setw()<<creditPlusGpa<<endl}}classList{public:vector<Course>datapublic:List(){}~List(){}voidadd(constCoursetemp){datapushback(temp)}在矢量尾添加一个元素voidsortdes(){sort(databegin(),dataend(),less<Course>())}升序排序voidsortasc(){sort(databegin(),dataend(),greater<Course>())}降序排序voidclearlist(){dataclear()}intgetAmount(){intcount=vector<Course>::iteratoriter=databegin()while(iter!=dataend()){countiter}returncount}voidshow(){inti=vector<Course>::iteratoriter=databegin()while(iter!=dataend()){cout<<left<<setw()<<iiter>show()}}用于输出运算后的内容floatgetCreditSum()获得学分和{floatsum=vector<Course>::iteratoriter=databegin()while(iter!=dataend()){sum=iter>getCredit()iter}returnsum}floatgetGpaSum()获得绩点和(Σ学分*绩点){floatsum=vector<Course>::iteratoriter=databegin()while(iter!=dataend()){sum=((iter>getCredit())*(iter>getGpa()))iter}returnsum}floatgetAverageGpa(){returngetGpaSum()getCreditSum()}}voiddeclaration()用于在程序之前输出内容声明voidstata()voidstatb()voidstatc()voidstatd()voidstate()Listlist数据矢量作为全局对象floatgpasum=floatcreditsum=floataveragegpa=Listlistvoidfunctionb()intmain(){declaration()功能实现打开文件载入数据生成数据库,显示数据ifstreaminfileinfileopen("txt")if(!infile)cout<<"文件打开失败~#请确认您的工作目录下包含文件"txt"!"<<endlelse{cout<<"a数据开始载入~"<<endl<<endlintno序号stringyear学年学期intcode课程代码stringname课程名称floatcredit学分intscore成绩stringquality成绩性质tringcourseQua课程性质sCoursecourseTempstring::sizetypepos={}stringdatastringbuf存储从文件中读来的一行数据while(getline(infile,buf)){istringstreaminStristringstreaminStr,inStr,inStrpos=buffindfirstnotof("")pos=buffindfirstof("",pos)data=bufsubstr(pos,pospos)cout<<data<<"x"<<endlif(data!="序号"){inStrstr(data)inStr>>noinStrsync()}elsecontinuefor(inti=i<=i){posi=buffindfirstnotof("",posi)posi=buffindfirstof("",posi)datai=bufsubstr(posi,posiposi)cout<<datai<<endl*switch(i){case:year=databreakcase:{istringstreaminStr(data)inStr>>codebreak}case:name=databreakcase:{istringstreaminStr(data)inStr>>creditbreak}case:{istringstreaminStr(data)inStr>>scorebreak}case:quality=databreak}*}year=datainStrstr(data)inStr>>codecout<<inStrstr()<<""<<code<<endlname=datainStrstr(data)inStr>>creditcout<<inStrstr()<<""<<credit<<endlif(data=="优")score=elseif(data=="良")score=elseif(data=="中")score=elseif(data=="及格")score=elseif(data=="不及格")score=else{inStrstr(data)inStr>>score}cout<<inStrstr()<<""<<score<<endl}quality=datacout<<left<<setw()<<no<<left<<setw()<<year<<left<<setw()<<name<<left<<setw()<<credit<<left<<setw()<<score<<left<<setw()<<quality<<endlcourseTempset(no,year,code,name,credit,score,quality)courseTempsetGpa()listadd(courseTemp)}}进行各门课程绩点的计算与设置cout<<endl<<"数据载入成功~可以进行运算了。"<<endl<<endllistshow()cout<<endlsystem("pause")<<"a我是华丽的分割线cout"<<endl<<endl进入功能菜单cout<<"请选择:"<<endlcout<<"a我要查看降序排列的成绩nnb我要查看降序排列的学科总绩点(=学分x绩点)nnc我要查看平均绩点。n"<<endl<<endlcout<<"请选择(不区分大小写):"charchoice=''cin>>choicecout<<endlboolend=falsewhile(){switch(choice){case'a':case'A':cout<<"n"<<endlcout<<"a按成绩从高到低:n"<<endllistsortasc()listshow()cout<<endlbreakcase'b':case'B':cout<<"n"<<endlfunctionb()cout<<'a'<<endlbreakcase'c':case'C':{cout<<"n"<<endlcout<<"a您的"<<listgetAmount()<<"门成绩:总学分为:"<<listgetCreditSum()<<"平均绩点为:"<<listgetAverageGpa()<<"。"<<endlend=truecout<<endlbreak}default:cout<<"对不起您的输入有误~"<<endl<<endlcout<<"an"<<endl}system("pause")cinsync()【】刷新cin缓冲区,,if(end==true){cout<<"a我是华丽的分割线"<<endlbreak}cout<<"a我是华丽的分割线n"<<endlcout<<"a我要查看降序排列的成绩nnb我要查看降序排列的学科总绩点(=学分x绩点)nnc我要查看平均绩点。n"<<endl<<endlcout<<"请选择(不区分大小写):"cin>>choicecout<<endl}::gpasum=listgetGpaSum()::creditsum=listgetCreditSum()::averagegpa=listgetAverageGpa()ofstreamoutoutopen("成绩结果输出txt")out<<"您的总学分为:"<<creditsum<<endlout<<"您的所有课程的平均绩点为:"<<averagegpa<<endlout<<"n"<<endl<<endloutclose()统计功能*按学期。学年统计学分和绩点低于平均绩点的学科对绩点贡献高于平均绩点的学科最不淡定的成绩高一分则增加多少绩点*end=falsewhile(true){cout<<endl<<endlcout<<"【统计功能菜单】n"<<endlcout<<"请选择:n"<<endlcout<<"a查看【低于平均绩点】的学科n"<<endlcout<<"b查看【高于平均绩点】的学科n"<<endlcout<<"c查看各【学期】获得的学分、绩点n"<<endlcout<<"d查看各【学年】获得的学分、绩点n"<<endlcout<<"e查看让你【不淡定】的学科。n"<<endlcout<<"f退出。n"<<endlcout<<"请选择:"cin>>choicecout<<"n"<<endlcinsync()cout<<endlswitch(choice){case'a':case'A':stata()breakcase'b':case'B':statb()breakcase'c':case'C':statc()breakcase'd':case'D':statd()breakcase'e':case'E':state()breakcase'f':case'F':cout<<"感谢您的使用~n"<<endlend=truebreakdefault:cout<<"对不起您的输入有误~"<<endl<<endlcout<<"an"<<endl}if(end)break}cout<<"aaaaaBy张哲仪器科学与工程学院级n"<<endlcout<<"程序终止。n"<<endlsystem("pause")system("pause")return}voidfunctionb(){vector<CourseSigma>listvector<Course>::iteratoriter=::listdatabegin()while(iter!=::listdataend()){(*iter)show()listpushback(CourseSigma(*iter))iter}sort(listbegin(),listend(),greater<CourseSigma>())cout<<left<<setw()<<"学年:"<<setw()<<"学科:"<<setw()<<"学分:"<<setw()<<"成绩:"<<setw()<<"绩点:"<<setw()<<"学分x绩点"<<endlvector<CourseSigma>::iteratoriter=listbegin()while(iter!=listend())(*iter)show()cout<<endl<<endl}voidstata()【低于平均绩点】{cout<<"n"<<endllistclearlist()for(vector<Course>::iteratoriter=listdatabegin()iter<listdataend()iter){if(iter>getGpa()<::averagegpa)listadd(*iter)}cout<<"您的【低于】平均绩点的课程如下:"<<endl<<endllistshow()cout<<endl<<endla我是华丽的分割线cout<<""<<endl<<endlsystem("pause")}voidstatb()【高于平均绩点】{cout<<"n"<<endllistclearlist()for(vector<Course>::iteratoriter=listdatabegin()iter<listdataend()iter){>getGpa()>::averagegpa)listadd(*iter)if(iter}cout<<"您的【高于】平均绩点的课程如下:"<<endl<<endllistshow()cout<<endl<<endlcout<<"a我是华丽的分割线"<<endl<<endlsystem("pause")}voidstatc()【学期】{cout<<""<<endlvector<string>semesterlistsemesterlistpushback(listdatafront()getYear())boolisinList=falsefor(vector<Course>::iteratoriter=listdatabegin()iter!=listdataend()iter){for(vector<string>::iteratoriter=semesterlistbegin()iter!=semesterlistend()iter){if((*iter)getYear()==*iter){isinList=truebreak}}if(isinList==false){cout<<(*iter)getYear()<<endlsemesterlistpushback((*iter)getYear())}isinList=false}intcountyears=semesterlistsize()vector<vector<Course>>listbyyear(countyears)vector<vector<Course>>::iteratoritercomplex=listbyyearbegin()vector<Course>::iteratoriterCoursevector<string>::iteratoriterstringfor(iterstring=semesterlistbegin()iterstring!=semesterlistend()iterstring){for(iterCourse=::listdatabegin()iterCourse!=::listdataend()iterCourse){if((*iterstring)==(*iterCourse)getYear())(*itercomplex)pushback(*iterCourse)}itercomplex}for(itercomplex=listbyyearbegin()itercomplex!=listbyyearend()itercomplex){cout<<endlcout<<(*itercomplex)front()getYear()<<"学期:n"<<endl*for(iterCourse=(*itercomplex)begin()iterCourse!=(*itercomplex)end()iterCourse){(*iterCourse)show()}*Listlisttemplisttempdataassign((*itercomplex)begin(),(*itercomplex)end())listtempshow()cout<<endlcout<<"该学期您取得的总学分为:"<<listtempgetCreditSum()<<"平均绩点为:"<<listtempgetAverageGpa()<<endlcout<<endlcout<<""<<endl}cout<<'a'<<endlsystem("pause")}voidstatd()【学年】{cout<<""<<endlvector<string>semesterlistsemesterlistpushback(listdatafront()getYear()substr(,))boolisinList=falsefor(vector<Course>::iteratoriter=listdatabegin()iter!=listdataend()iter){for(vector<string>::iteratoriter=semesterlistbegin()iter!=semesterlistend()iter){if((*iter)getYear()substr(,)==*iter){isinList=truebreak}}if(isinList==false){cout<<(*iter)getYear()<<endlsemesterlistpushback((*iter)getYear()substr(,))}isinList=false}intcountyears=semesterlistsize()vector<vector<Course>>listbyyear(countyears)vector<vector<Course>>::iteratoritercomplex=listbyyearbegin()vector<Course>::iteratoriterCoursevector<string>::iteratoriterstringfor(iterstring=semesterlistbegin()iterstring!=semesterlistend()iterstring){for(iterCourse=::listdatabegin()iterCourse!=::listdataend()iterCourse){if((*iterstring)==(*iterCourse)getYear()substr(,))(*itercomplex)pushback(*iterCourse)}itercomplex}for(itercomplex=listbyyearbegin()itercomplex!=listbyyearend()itercomplex){cout<<endlcout<<(*itercomplex)front()getYear()substr(,)<<"学年:n"<<endl*for(iterCourse=(*itercomplex)begin()iterCourse!=(*itercomplex)end()iterCourse){(*iterCourse)show()}*Listlisttemplisttempdataassign((*itercomplex)begin(),(*itercomplex)end())listtempshow()cout<<endlcout<<"该学年您取得的总学分为:"<<listtempgetCreditSum()<<"平均绩点为:"<<listtempgetAverageGpa()<<endlcout<<endlcout<<""<<endl}cout<<'a'<<endlsystem("pause")}voidstate()【不淡定】{cout<<"n"<<endlcout<<"功能简介:n"<<endlcout<<"此功能将统计您的成绩的个位为,,的学科nn在此情况下,当您的成绩再增加分,您的绩点会相应的上升一个等级nn"<<endlcout<<"友情提示:nn老师必定也不会故意将您的成绩绩点降低等级的,要相信老师已经努力帮您提分了nn所以当您看到结果时,就请不要在心中默默问候老师了囧rznn"<<endlvector<Course>listNotCalmintmod=for(vector<Course>::iteratoriter=listdatabegin()iter!=listdataend()iter){mod=(*iter)getScore()if(mod==||mod==||mod==)listNotCalmpushback(*iter)}if(listNotCalmsize()==)cout<<"恭喜您!老师都很给力啊!"<<endlelse{cout<<left<<setw()<<"学年:"<<setw()<<"学科:"<<setw()<<"学分:"<<setw()<<"成绩:"<<setw()<<"性质:"<<setw()<<"绩点:"<<endlfor(vector<Course>::iteratoriter=listNotCalmbegin()iter!=listNotCalmend()iter)(*iter)show()cout<<endlcout<<""<<endlcout<<'a'<<endlsystem("pause")}voiddeclaration()用于在程序之前输出内容声明{cout<<""<<endlcout<<endlcout<<"********************************************"<<endl再版声明cout<<"*【东南大学】学分绩点计算器升级版*"<<endlcout<<"********************************************"<<endlcout<<"By张哲"<<endlcout<<"From【仪科学院】"<<endlcout<<"发布"<<endlcout<<""<<endl程序使用说明cout<<"What'sNEW~(新版本更新了什么功能)"<<endlwhat'snewcout<<"美化输出格式nn使用STL库优化内存管理nn新增nn新增多种绩点分析功能nn优化了数据读入无需计算总学分功能手动修改"优良中及格"形式的成绩。n"<<endlcout<<"请按任意键进入“使用说明”界面。n"<<endlsystem("pause")cout<<"a我是华丽的分割线"<<endlcout<<"nn【使用说明:】"<<endl<<endlcout<<"打开校园网的【学生登录】网页并登入【成绩服务】【成绩查询】n"<<endlcout<<"将成绩表格全部复制下来(【注意】:最下面的【学年】和【总学分】两行不要~)n"<<endlcout<<"将刚刚复制的表格粘贴在”txt“。【请保证文件与该程序在【同一目录下】】n"<<endlcout<<"请自行删去【不计算绩点】的诸如人文,经管,自然科学等课程n"<<endlcout<<"如果您确保以上操作已经正确执行,n"<<endlsystem("pause")cout<<"n"<<endlcout<<"n"<<endlcout<<endlcout<<endlcout<<"a我是华丽的分割线"<<endl}

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/28

学分和绩点计算器

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利