问题 问答题

以下是某C程序段及其功能描述,请仔细阅读程序并完成要求
企业发放的奖金根据利润提成,发放规则如下:
利润(Ⅰ)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成。从键盘输入当月利润Ⅰ,输入应发放奖金总数。
#include
#include
int main()
{
long int gain;
int prizel, prize2, prize4, prize6, prize10,prize=0;
puts("************************************");
puts("* The program will solve *");
puts(" * the problem of prize distribution * "):
puts(" ************************************");
puts("please input the mum of gain:");
scanf("%ld", &gain);
prizel=100000*0.1:
prize2=prizel+i00000*0.075:
prize4=prize2+200000*0.05:
prize6=prize4+200000*0.03:
prize10=prize6+400000*0.015:
if(gain<=100000)
prize=gain*0.1:
else if(gain<=200000)
prize=prizel+(gain-i00000)*0.075;
else if(gain<=400000)
prize=prize2+(gain-200000)*0.05:
else if(gain<=600000)
prize=prize4+(gain-400000)*0.03:
else if(gain<=1000000)
prize=prize6+(gain-600000)*0.015;
else
prize=prize10+(gain-i000000)*0.01;
printf("The prize is:%d\n", prize);
getch();
return 0;

设计一组测试用例,使该程序所有函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该程序的语句或分支覆盖率无法达到100%,需说明为什么。

答案

参考答案:

解析:为了使该程序满足分支覆盖和语句覆盖,应该设计测试用例,使其覆盖每一种情况。用例设计如下: Gain=20000,180000,350000,560000,970000,1200000。

阅读理解

阅读理解。

      A good way to pass an exam is to work hard every day in a year. You may fail in the exam if you are lazy

(懒惰) for most of the year and then work hard only a few days before the exam. If you are taking an English

exam, do not only learn rules of grammar. Try to read stories in English. Speak in English whenever you can.

A few days before the exam you should go to bed early. Do not stay up late studying. Before you start the exam,

read carefully over the question paper, try to understand the exact (确切的) meaning of each question. When

you have at last finished your exam, read over your answers. Correct (改正) the mistakes if there are any, and

be sure that you have not missed anything out.

1. How can we do well in exams? [ ]

A. We should work hard every day in the year.

B. We should go to bed early a few days before an exam.

C. We should read over the answers before we hand in our papers.

D. We should do A, B, C.

2. Learning rules of grammar ________ to pass an exam. [ ]

A. is enough

B. is not enough

C. is not impossible

D. is no use

3. Speak in English whenever you can. It is _______ to your English study. [ ]

A. helpful

B. impossible

C. wonderful

D. foolish

4. Make sure that you _______ before you hand in your paper. [ ]

A. remember rules of grammar

B. have thought over and over again

C. have answered all the questions

D. have read stories in English

5. In the sentence "Do not stay up late at night studying", the expression "stay up" means _______. [ ]

A. 逗留

B. 呆坐

C. 熬夜

D. 停止

判断题