Write a program that prompts the user to enter a letter grade A, B, C, D, or F and displays its corresponding numeric value 4, 3, 2, 1, or 0.
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a letter grade: "); String ch = input.next(); input.close(); Map<String, Integer> gradeMap = new HashMap<>(); gradeMap.put("A", 4); gradeMap.put("B", 3); gradeMap.put("C", 2); gradeMap.put("D", 1); gradeMap.put("F", 0); Integer value = gradeMap.get(ch); System.out.println("The numeric value for grade " + ch + " is " + value); }
Enter a letter grade: A The numeric value for grade A is 4