Introduction
In this challenge, a local high school needs a digital grading system to automatically convert numerical scores into letter grades. The goal is to practice using multi-branch if-else statements to create a simple grade conversion program that handles scores from 0 to 100 with appropriate grade classifications.
Implement Grading System with If-Else
A local high school needs a digital grading system to automatically convert numerical scores into letter grades. This challenge will help you practice using multi-branch if-else statements to create a simple grade conversion program.
Tasks
- Create a C++ program that converts numerical scores to letter grades
- Implement a multi-branch if-else statement to map scores to grades
- Handle scores from 0 to 100 with appropriate grade classifications
Requirements
- Create a file named
grade_converter.cppin the~/projectdirectory - Use a multi-branch if-else statement for grade conversion
- Define grade ranges as follows:
- 90-100: A
- 80-89: B
- 70-79: C
- 60-69: D
- 0-59: F
- Program should take a numerical score as input and output the corresponding letter grade
- Use
std::coutto display the final grade
Examples
After implementing the grade conversion logic, you can test the program by running it and entering different numerical scores to see the corresponding letter grades.
## Compile the program
g++ -o grade_converter grade_converter.cpp
## Run the program
./grade_converter
## Test Case 1: A Grade
Enter your numerical score (0-100): 95
A
## Test Case 2: C Grade
Enter your numerical score (0-100): 75
C
## Test Case 3: F Grade
Enter your numerical score (0-100): 55
F
## Test Case 4: Invalid Input
Enter your numerical score (0-100): 150
Invalid score. Please enter a score between 0 and 100.
Hints
- Remember to use if-else statements with comparison operators
- Check conditions from highest to lowest grade ranges
- Use
std::cinto get user input - Ensure your conditions cover all possible score inputs
Summary
In summary, this challenge requires the implementation of a C++ program that converts numerical scores to letter grades using a multi-branch if-else statement. The program should handle scores from 0 to 100 and map them to the appropriate grade classifications: A (90-100), B (80-89), C (70-79), D (60-69), and F (0-59). The program should take a numerical score as input and output the corresponding letter grade using std::cout.



