Write in java a client that creates a symbol table mapping l

Write, in java, a client 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 numbers corresponding to the grades).

B A+ A A 4.33 4.003.67 3.33 3.00 2.67 2.33 2.00 1.67 1.00 0.00 C+C .33T 3.00 12.67 T 2.33T 2.00|1.67 T 1.00 f 0.00 C+ 267 2.33 | 2.00 1.67 1.00 0.00 B+ BB

Solution

import java.util.HashMap;
import java.util.Scanner;

class Grade{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);

HashMap<String, Double> map = new HashMap<String, Double>();
map.put(\"A+\", 4.33);
map.put(\"A\", 4.00);
map.put(\"A-\", 3.67);
map.put(\"B+\", 3.33);
map.put(\"B\", 3.00);
map.put(\"B-\", 2.67);
map.put(\"C+\", 2.33);
map.put(\"C\", 2.00);
map.put(\"C-\", 1.67);
map.put(\"D\", 1.00);
map.put(\"F\", 0.00);

String ch = \"Y\";
double count = 0.00, sum = 0.00;
while(ch.equals(\"Y\")){
   System.out.println(\"Enter grade: \");
   String g=sc.next();
   if(!map.containsKey(g)){
       System.out.println(\"Invalid key\");
       continue;
   }
   System.out.println(\"More Grades ? (Y/N)\");
   ch=sc.next();
   count++;
   sum += map.get(g);
}
System.out.println(\"GPA = \"+ sum / count);
sc.close();
}
}

Write, in java, a client that creates a symbol table mapping letter grades to numerical scores, as in the table below, then reads from standard input a list of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site