⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex0216.cpp

📁 《C++编程习题与解答》书中所有例题与习题的源代码
💻 CPP
字号:
//  Programming with C++ by John R. Hubbard
//  Copyright McGraw-Hill, 1999
//  Example 2.16 on page 38
//  Using the else if construct

#include <iostream>
using namespace std;

int main()
{ // prints the grade for an input test score:
  int score;
  cout << "Enter your test score: ";  cin >> score;
  if (score > 100) cout << "Error: that score is out of range.";
  else if (score >= 90) cout << "Your grade is an A." << endl;
  else if (score >= 80) cout << "Your grade is a B." << endl;
  else if (score >= 70) cout << "Your grade is a C." << endl;
  else if (score >= 60) cout << "Your grade is a D." << endl;
  else if (score >=  0) cout << "Your grade is an F." << endl;
  else cout << "Error: that score is out of range.";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -