Final answer:
The question is about writing a Python program to read scores from the keyboard and assign letter grades, exiting when a sentinel value is entered. An example code is provided demonstrating the use of a while loop and an if-elif-else structure to process the input and print the corresponding letter grades.
Step-by-step explanation:
The student is asking for assistance in writing a program that reads scores from the keyboard and assigns letter grades based on the scores until a sentinel value is entered to stop the loop. This task is commonly assigned in computer programming courses and reinforces skills in control structures, particularly loops and conditional statements.
To achieve this, the program could be written in various programming languages. In this example, I'll use Python, which is known for its readability and simplicity. The program will prompt the user to enter a score, convert the score to a letter grade, and then print the letter grade. If the sentinel value (for example, -1) is entered, the program will terminate.
# This is the sample Python program.
def main():
sentinel = -1
score = int(input("Enter a score (or -1 to stop): "))
while score != sentinel:
if score >= 90:
grade = 'A'
elif score >= 80:
grade = 'B'
elif score >= 70:
grade = 'C'
elif score >= 60:
grade = 'D'
else:
grade = 'F'
print(f'The letter grade for {score} is {grade}')
score = int(input("Enter a score (or -1 to stop): "))
if __name__ == '__main__':
main()
As seen in the code above, the program uses a while loop to continually prompt the user for scores until the sentinel value is entered. The if-elif-else block is used to map numerical scores to their corresponding letter grades before the loop is exited. To use this program, replace the example sentinel value with the appropriate value for the context in which you're working.
The complete question is: Write a program to enter scores from the keyboard and print the letter grade using a sentinel loop. The loop will stop when the user enter a sentinel value. is: