C++ Primer(第5版) 练习 5.5
练习 5.5 写一段自己的程序,使用if else语句实现把数字成绩转换成字母成绩的要求。
环境:Linux Ubuntu(云服务器)
工具:vim
代码块
/*************************************************************************> File Name: ex5.5.cpp> Author: > Mail: > Created Time: Sun 11 Feb 2024 10:24:49 AM CST************************************************************************/#include<iostream>
using namespace std;int main(){int grade;cout<<"Enter Grade: ";cin>>grade;cout<<"Grade: ";if(grade >= 90){cout<<"A";}else if(grade >= 80){cout<<"B";}else if(grade >= 70){cout<<"C";}else if(grade >= 60){cout<<"D";}else{cout<<"E";}if(grade == 100){cout<<"++";}if(grade >= 60 && grade != 100){if(grade % 10 > 7){cout<<"+";}else if(grade % 10 < 3){cout<<"-";}}cout<<endl;return 0;
}