Cpp - Write program to use switch statement to check single character input

Requirements

Write program to use switch statement to check single character input

Hint

No need to check the lower case value.

Demo

#include <iostream>
  
int main()//from w w  w .j a v a  2s  .  c o  m
{
    char grade;
    std::cout << "Enter your letter grade (ABCDEFG): ";
    std::cin >> grade;
    switch (grade)
    {
    case 'A':
        std::cout << "A!\n";
        break;
    case 'B':  
        std::cout << "B!\n";
        break;
    case 'C':  
        std::cout << "C!\n";
        break;
    case 'D':  
        std::cout << "D!\n";
        break;
    case 'E':
        std::cout << "E!\n";
        break;
    case 'F':  
        std::cout << "F!\n";
        break;
    case 'G':
        std::cout << "G!\n";
        break;
    default: 
        std::cout << "other!\n";
        break;
    }
    return 0;
}

Result

Related Exercise