Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need your help to answer this question correctly. please also post pictures of

ID: 3592070 • Letter: I

Question


I need your help to answer this question correctly. please also post pictures of input and output as my professor needs it. I need to get it done correctly


Assignment 6b Write a client program grade.java that creates a symbol table mapping letter grades to numerical scores, as in the table below, then reads from standard input a list of letter grades and computes and prints the GPA (the average of the numerical scores of the corresponding grades). Specify which method you are using (ordered/unordered array, linked list etc...) Use the following as input and print the symbol table out and the GPA A+ 4.33 4.00 3.67 3.33 3.00 2.67 2.33 2.00 1.67 1.00 0.00

Explanation / Answer

We are usign a hash map to store grade and gpa table.Below is the code

import java.util.*;
public class Grade{

public static void main(String []args){

HashMap<String,Double> symbol_table=new HashMap<String,Double>();

symbol_table.put("A+",4.33);
symbol_table.put("A",4.00);
symbol_table.put("A-",3.67);
symbol_table.put("B+",3.33);
symbol_table.put("B",3.00);
symbol_table.put("B-",2.67);
symbol_table.put("C+",2.33);
symbol_table.put("C",2.00);
symbol_table.put("C-",1.67);
symbol_table.put("D",1.00);
symbol_table.put("F",0.00);

int n,i;
String[] grade;
Scanner sc = new Scanner(System.in);

System.out.println("Enter the number of grades");
n=sc.nextInt();
grade=new String[5];

System.out.println("Enter the grades");
for(i=0;i<n;i++)
grade[i]=sc.next();

double average=0;
for(i=0;i<n;i++)
{
System.out.println("GPA for Grade "+grade[i]+" is "+symbol_table.get(grade[i]));
average=average+symbol_table.get(grade[i]);
}
System.out.println("GPA after calculating Average is "+average/n);

}
}

First number of grade will be inputted ,followed by grades

Sample Input

4
A
A+
C+
B-

Sample Output