面向对象的c++程序设计第六版课后习题答案第十章文档格式.docx
- 文档编号:15999400
- 上传时间:2022-11-17
- 格式:DOCX
- 页数:24
- 大小:24.29KB
面向对象的c++程序设计第六版课后习题答案第十章文档格式.docx
《面向对象的c++程序设计第六版课后习题答案第十章文档格式.docx》由会员分享,可在线阅读,更多相关《面向对象的c++程序设计第六版课后习题答案第十章文档格式.docx(24页珍藏版)》请在冰豆网上搜索。
doublequiz2;
doublemidterm;
doublefinal;
doubleaverage;
chargrade;
};
voidinput(StudentRecord&
student);
voidcomputeGrade(StudentRecord&
voidoutput(constStudentRecordstudent);
intmain()
StudentRecordstudent[CLASS_SIZE];
for(inti=0;
i<
CLASS_SIZE;
i++)
input(student[i]);
<
<
"
Theseare100pointtests\n"
;
cin>
>
>
;
cout<
endl<
endl;
}
student)
n"
abort();
}
=letterGrade[index];
voidoutput(constStudentRecordstudent)
Therecordforstudentnumber:
endl
Thequizgradesare:
Themidtermandexamgradesare:
Thenumericaverageis:
andthelettergradeassignedis"
Dataforthetestrun:
17109095
2989080
3787080
4585070
5404035
Commandlinecommandtoexecutethetextrun:
ch10prg1<
data
Output:
enterthestudentnumber:
1
entertwo10pointquizes
710
enterthemidtermandfinalexamgrades.Theseare100pointtests
9095
2
98
9080
3
78
7080
4
58
5070
5
40
4035
710
9095
andthelettergradeassignedisA
98
9080
andthelettergradeassignedisB
78
7080
andthelettergradeassignedisC
58
5070
andthelettergradeassignedisD
40
4035
andthelettergradeassignedisF
*/
2.RedefineCDAccountfromDisplaytobeaclassratherthanstruct.
Usethesamevariables,makethemprivate.
Addmemberfunctions:
toreturninitialbalance
toreturnbalanceatmaturity
toreturninterestrate
toreturntheterm
defaultconstructor
constructortosetspecifiedvalues
inputfunction(istream&
);
outputfunction(ostream&
Embedinatestprogram
ThecodeinDisplaymakesthebehavioroftherequiredfunctionsclear.
Noteoncapitalizationschemes:
Iuseaslightlydifferentcapitalizationschemethantheauthor.Youshouldmakeyourconventionscleartothestudent.Anycapitalizationthatproducesreadablecodeisacceptabletothisauthor.Theinstructor,asalways,isleftfreetodoasiswished.
CDaccount,differentinterface
RedothedefinitionofclassCDAccountfromProject2sothattheinterfaceisthesamebuttheimplementationisdifferent.ThenewimplementationissimilartothesecondimplementationofBankAccountinDisplay.Herethebalanceisrecordedintwointvalues,onefordollars,oneforcents.Themembervariableforinterestratestorestheinterestasafractionratherthanapercentage.TermisstoredasinProject2.
Remark:
Thechangestobemadeareinthefunctionsthattakebalanceasargument.Theimplementationofthemembersmustchange:
1)togeneratetheintobjectsdollarsandcentsfromtheexternalrepresentationofbalance(adouble)
2)totakedollarsandcents(intobjects)fromtheinternalrepresentationandgeneratetheexternalinformation.
interestrateisadouble(decimal)fractionrather
termisstoredthesame
#include<
iostream>
usingnamespacestd;
classCDAccount
public:
CDAccount();
CDAccount(doublebal,doubleintRate,intT);
doubleInterestRate();
doubleInitialBalance();
doubleBalanceAtMaturity();
intTerm();
voidinput(istream&
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 面向 对象 c+ 程序设计 第六 课后 习题 答案 第十