综合应用实例
7页1、综合应用实例实现一个简单的学生成绩录入和查询系统。具体要求如下:(1)能够输入学生的学号、姓名和各科成绩。(2)根据输入的学号,查询并计算出该生的各科成绩及平均分。(3)根据输入的课程代号,查询并计算出该课程中每个学生的成绩及课程平均分。(4)查询所有课程中成绩不及格的学生名单及相应成绩。程序分析:学生成绩用文本文件来存储,能够从文本文件里读出学生的信息,也能够向文本文件中写入学生的信息。程序中对插入和提取运算符进行了重载。程序依次有5项功能:学生信息的添加;输入学号,输出该生各科成绩及平均分;输入课程代号,输出该课程每位学生成绩及课程平均分;输入学生姓名,输出成绩;设计功能选择菜单及利用switch case语句实现以上功能。程序如下: #include#include#include#include#includeint count; /学生人数class Student /学生类定义private:char Name20; /姓名char Number20; /学号double Chinese,Math,English,Computer; /语文,数学,英语,计算机成绩publi
2、c:Student()char *getname()return Name;double getscore(char n)double score;switch(n)case c: score=Chinese; break;case m: score=Math; break;case e: score=English; break;case p: score=Computer; break;return score;char *getNumber()return Number;friend ofstream& operator (ofstream &dist,Student &st); /重载插入运算符friend ostream &operator (istream &sour,Student &st); /重载提取运算符friend ifstream &operator (ifstream&sour,Student &st);ofstream &operator (ofstream&dist,Student &st) /重载插入运算符 distst.Nametst.Numberts
3、t.Chinesetst.Mathtst.Englishtst.Computerendl;return dist;ostream &operator (ostream&dist,Student &st) /重载插入运算符 dist姓名:st.Namet学号:st.Numbert语文:st.Chineset数学:st.Matht英语:st.Englisht计算机:st.Computert (istream&sour,Student &st) /重载提取运算符coutst.Name;coutst.Number;coutst.Chinese;coutst.Math;coutst.English;coutst.Computer;return sour;ifstream &operator (ifstream&sour,Student &st) /重载提取运算符sourst.Name;sourst.Number;sourst.Chinese;sourst.Math;sourst.English;sourst.Computer;return sour;Student s100; /对象数组void
《综合应用实例》由会员cn****1分享,可在线阅读,更多相关《综合应用实例》请在金锄头文库上搜索。
解决问题27 (2).doc
平行四边形的面积8.docx
精品资料(2021-2022年收藏)教你如何写一篇好的述职报告
建筑安全知识竞赛题库
2022-2023学年福建闽侯第六中学英语高三上期末学业水平测试试题含解析.doc
地铁工程安全及风险管理研究.docx
第10周-假设法解题
裂缝导流能力实验 ++++.doc
通信工程质量监督现场检查记录表
过程参数检测及仪表复习资料.doc
Dmcozj2011高中数学公式大全Word版
意大利公司评价.doc
关于课件中超链接录音的说明
汽车文案全集.doc
三年级上学期小学语文摸底突破三单元真题模拟试卷(16套试卷).docx
五年级数学教案第四单元实力评价22
厚朴的资源及药理研究进展.doc
课后分层作业
电力系统继电保护模拟试题(二)及答案.doc
新人入职培训操作手册
2024-02-15 4页
2023-09-01 12页
2023-09-15 30页
2022-09-11 7页
2022-09-30 11页
2022-08-03 7页
2023-10-03 13页
2022-10-08 15页
2023-10-03 2页
2023-03-24 12页