Q:

Using an if–else statement, write your own version of the program to generate the letter grade from a numeric grade

0

Using an if–else statement, write your own version of the program to generate the letter grade from a numeric grade.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <vector>
#include <string>
#include <iostream>

int main() {
  const std::vector<std::string> scores = { "F", "D", "C", "B", "A", "A++"};
  std::string lettergrade;
  int grade;
  std::cin >> grade;
  if (grade >= 60)
    lettergrade = scores[(grade - 50) / 10];
  else
    lettergrade = scores[0];
  std::cout << lettergrade << std::endl;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now