[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc

上传人:appealoxygen216 文档编号:497425 上传时间:2018-11-28 格式:DOC 页数:9 大小:63.50KB
下载 相关 举报
[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc_第1页
第1页 / 共9页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc_第2页
第2页 / 共9页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc_第3页
第3页 / 共9页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc_第4页
第4页 / 共9页
[计算机类试卷]国家二级C++机试(操作题)模拟试卷343及答案与解析.doc_第5页
第5页 / 共9页
点击查看更多>>
资源描述

1、国家二级 C+机试(操作题)模拟试卷 343及答案与解析 一、基本操作题 1 请使用 VC6或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1。该工程中包含程序文件 main cpp,其中有类 CDate(“日期 ”)和主函数 main的定义。程序中位于每个 “ ERROR *found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 原日期: 2005925 更新后的日期: 200641 注意:只修改每个 “ ERROR*found*”下的那一行 不要改动程序中的其他内容。 #include #include USing namespace std; class

2、 CDate日期类 ERROR*found* protected: CDaLe(); CDate(int d, int m, int y) ERROR*found* SefiDafie(int day=d, int month=m, int year=y); ; void Display():显示日期 void SetDate(int day, int month, int year) 设置日期 m_nDay=day; m_nNonfih=month;m_ nYear=year; private: int m_nDay; /日 int m nNonth;月 int m nYear;年 , vo

3、id CDate: Display()显示日期 ERROR*found* cout using namespace std; class Room “房间 ”类 int room no; 房间号 double length; 房间长度 (m) double width; 房间宽度 (m) public: Room(int the room_no, double the_ length, double the_width): room_no (the_room_no), length(the_length), width(the_width) int theRoomNo()constreturn

4、 room_ no; /返回房间号 double theLength()constreturn length; ) 返回房间长度 double theWidth()constreturn width; 返回房间宽度 /* found* double theArea()const_ 返回房间面积 (矩形面积 ) ; class Office: public Room “办公室 ”类 char*depart; /所属部门 public: Office(int the room no, double the length, double the width, const char*thedepart

5、) * found* : _ depart=new char | strlen(the depart)+1 j; *found* strcpy(_); 一 Office()deletedepart; ) const char*theDepartment()const return depart; 返回所属部门 ; int main() *found* Office_; cout #include using namespace std; class Basel public: *found*下列语句需要 声明纯虚函数 Show _; , clasS Base2 protected: char*

6、p; Base2(const char*s) _P=new charstrlen(s)+1; *found*下列语句将形参指向的字符串常量复制到该类的字符数组中 _; 一 Base2()delete_P; ; *found*Derived类 公有继承 Base1,私有继承 Base2类 class Derived: _ public: *found*以下构造函数 调用 Base2类构造函数 Derived(const char*s): _ void Show() coutShow(); delete pb; return 0; 三、综合应用题 4 请使用 VC6或使用【答题】菜单打开考生文件夹

7、 prog3下的工程 prog3,其中包含了类 TaxCalculator(“个税计算器 ”)和主函数 main的定义。创建 “个税计算器 ”需要接收税率表信息和起征额信息。在 main函数中,通过两个数组创建了如下的税率表: 利用这个税率表创建 “个税计算器 ”时,假定起征额为 2 000元 (即不超过 2 000元的所得不征收个人所得税 )。请补充完成计算应纳个人所得税额的成员函数 getTaxPayable,其中的参数income为月收入。此程序的正确输出结果应为: 月收入为 800元 时应缴纳个人所得税 0元 月收入为 1 800元时应缴纳个人所得税 0元 月收入为 2 800元时应缴

8、纳个人所得税 55元 月收入为 3 800元时应缴纳个人所得税 155元 月收入为 4 800元时应缴纳个人所得税 295元 月收入为 5 800元时应缴纳个人所得税 455元 注意:只能在函数 getTaxPayable中的 “ *333*”和 “*666*”之间填入若干语句,不要改动程序中的其他内容。 /TaxCalculator h #include #include using namespace std; clasS TaxCalculator public: TaxCalculator(double the_limits, double the rates, int the len

9、gth, double the_threshold) : lower limits(new doublethe length), rates(new doublethelength ), list_len(the_length), thresh-old(the threshold) for(int i=0;i=0) *333* *666* 一一 i; return tax payable; void TaxCalculator: showTaxPayable (double income)const cout 国家二级 C+机试(操作题)模拟试卷 343答案与解析 一、基本操作题 1 【正确答

10、案】 (1)public: (2)SetDate(d, m, y); (3)coutlower limitsi) 如果 taxable(收入超出起征额的部分 ) 大于 lower limitsi阶段最低限额 tax_payable += (taxable lower limitsi)*ratesi; 把起过阶段最低 限额的部分乘以该阶段的税 率后,加到 tax_payable(个人所得税 ) taxable=lower limitsi; 把 fower limitsi赋值于 taxable 【试题解析】 主要考查考生对成员函数的掌握情况,根据题目要求可知,完成计算应纳个人所得税额的成员函数 getTaxPayable,其中参数 income为月收入。同时题目还表明:不超过 2000元的所得不征收个人所得税。因此先用 if语句判断是否要征收个人所得税。然后根据题目所给表格,来判断收入多少及应该收 多少个人所得税。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试资料 > 职业资格

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1