给出一个百分制成绩 要求输出成绩等级 (谭浩强c++程序设计第3版答案)

2016-06-15 17:17:01  分类: c++程序设计第三版谭浩强课后答案  参与:

 给出一百分制成绩,要求输出成绩等级‘A’,’B’,’C’,’D’,’E’。 90分以上为‘A’,80~89分为’B’,70~79分为’C’,60~69分为’D’,60分以下为’E’。

以下是【c++源代码】,需要C源代码的请点击
#include <iostream>
using namespace std;
int main ()
 {float score;
  char grade;
  cout<<"please enter score of student:";
  cin>>score;
  while (score>100||score<0)
    {cout<<"data error,enter data again.";
      cin>>score;
     }
 switch(int(score/10))
       {case 10:
        case 9: grade='A';break;
        case 8: grade='B';break;
        case 7: grade='C';break;
        case 6: grade='D';break;
        default:grade='E';       
       }
   cout<<"score is "<<score<<", grade is "<<grade<<endl;
   return 0;
}

来源:c++程序设计第三版谭浩强课后答案

本文链接:http://www.wb98.com/cjia/post/cjia_3.11.html


本站文章搜索:

<< 上一篇下一篇 >>

搜索

Tags列表

赞助商链接