- 2
- 0
- 约3.15千字
- 约 6页
- 2026-02-01 发布于北京
- 举报
练习(第4章):
在这个练习中,您将编写一个简单的程序来测试您对数据、参数、选择文本和默认
值的理解。
目标完成此练
习后,您将能够:
完成此练习后,您将能够:
•理解不同的数据类型和,并使用选择文本
完成此练习的预计时间:60分钟
练习以下
练习了在第4章中学到的概念的实践机会。
练习1:
将你的程序命名为YIN003_XX。创建以下输出。你应该使用参数语句获取用户的
和生日。使用选择文本使参数更加用户友好。将你自己的和生日设置为默
认值。你的程序应根据输入的日期计算用户的(以天数表示)。在这个程序中
我们不考虑错误处理,所以不必担心用户输入无效的日期。SY‑DATUM在这个程
序中非常有用。尝试将你的生日参数为TYPED和LIKESY‑DATUM,并观
察程序功能的不同。参考开发课程YINTRODUCTION中的程序YIN003获取解
决方案。
Exercise(Chapter4):
Inthisexercise,youwillwriteasimpleprogramtotestyourunderstandingofdata
declarations,parameters,selectiontextsanddefaultvalues.
Objectives
Aftercompletingthisexercise,youwillbeableto:
•Understanddifferentdatatypesanddeclarationsandusingselectiontexts
Estimatedtimetocompletethisexercise:60minutes
Exercises
ThefollowingexerciseprovidespracticeworkingwiththeconceptslearnedinChapter4.
Exercise1:
NameyourprogramYIN003_XX.Createthefollowingoutput.Youshouldgettheuser’s
nameandbirthdaywithaparametersstatement.Useselectiontextstomakethe
parametersmoreuser-friendly.Putyourownnameandbirthdayasthedefaults.Your
programshouldthencalculatehowmanydaysoldtheuseris,basedonthedateentered.
Wewillnotworryabouterror-handlinginthisprogram,sodon’tworryaboutwhetheror
nottheuserentersaninvaliddate.SY-DATUMwillcomeinveryhandyforthis
program.TrydeclaringyourbirthdayparameterasTYPED,andalsoLIKESY-DATUM,
andseethedifferenceinfunctionalityofyourprogram.RefertoProgramYIN003in
DevelopmentClassYINTRODUCTIONforthesolution.
练习2命名你的
程序YIN004_XX。编写一个程序,要求用户输入10个整数,然后将它
们相加并显示总和。你应该设置默认值。参考YINTRODUCTION中的程
序YIN004获取解决方案。
原创力文档

文档评论(0)