138k views
3 votes
Write a program that takes input as a string letter grade from the keyboard and translates it to a grade range. For example, if a user enters "A", the program should output "90-100". a) Python b) Java c) C++ d) JavaScript

User DoctorG
by
8.4k points

2 Answers

4 votes

Final answer:

To write a program that translates a letter grade to a grade range, you can use Python, Java, C++, or JavaScript.

Step-by-step explanation:

To write a program that takes input as a string letter grade and translates it to a grade range, you can use any of the given programming languages: Python, Java, C++, or JavaScript.

Here's an example in Python:

grade = input('Enter a letter grade: ')
if grade == 'A':
print('90-100')
elif grade == 'B':
print('80-89')
elif grade == 'C':
print('70-79')
elif grade == 'D':
print('60-69')
else:
print('Below 60')

This program prompts the user to enter a letter grade and then outputs the corresponding grade range.

User Ceyda
by
8.8k points
5 votes

This program defines a function letter_grade_to_range that takes a letter grade as input and returns the corresponding grade range. The main part of the program then takes user input, calls the function, and displays the result.

def letter_grade_to_range(letter_grade):

if letter_grade == 'A':

return '90-100'

elif letter_grade == 'B':

return '80-89'

elif letter_grade == 'C':

return '70-79'

elif letter_grade == 'D':

return '60-69'

elif letter_grade == 'F':

return '0-59'

else:

return 'Invalid grade'

# Get input from the user

user_input = input("Enter the letter grade: ")

# Convert the letter grade to a grade range

result = letter_grade_to_range(user_input.upper())

# Display the result

print(f"The grade range for {user_input.upper()} is: {result}")

User Sadat
by
8.1k points