Question

Write a java client that creates a symbol table mapping letter grades to numerical scores, as...

Write a java 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) USING SYMBOL TABLES. IN JAVA PLZ

A+

A

A-

B+

B

B-

C+

C

C-

D+

D

D

F

4.35

4.00

3.65

3.35

3.00

2.65

2.35

2.00

1.65

1.35

1

.65

0.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class AverageGrade {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String grade = "";

int count = 0;

double sum = 0;

while (true) {

System.out.println("Enter grade (Q to quit)");

grade = sc.nextLine();

if (grade.equalsIgnoreCase("Q"))

break;

count++;

sum += getValue(grade);

}

System.out.printf("Average GPA is %.2f: ",(sum/count));

}

private static double getValue(String line) {

line=line.toUpperCase();

double gpa = 0;

if (line.equals("A+"))

gpa = 4.35;

if (line.equals("A"))

gpa = 4;

if (line.equals("A-"))

gpa = 3.65;

if (line.equals("B+"))

gpa = 3.35;

if (line.equals("B"))

gpa = 3;

if (line.equals("B-"))

gpa = 2.65;

if (line.equals("C+"))

gpa = 2.35;

if (line.equals("C"))

gpa = 2;

if (line.equals("C-"))

gpa = 1.65;

if (line.equals("D+"))

gpa = 1.35;

if (line.equals("D"))

gpa = 1;

if (line.equals("D-"))

gpa = .65;

if (line.equals("F"))

gpa = 0;

return gpa;

}

}

Add a comment
Know the answer?
Add Answer to:
Write a java client that creates a symbol table mapping letter grades to numerical scores, as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3.1.1 Write a client that creates a symbol table mapping letter grades to numerical scores, as...

    3.1.1 Write 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). A+ | A | A- | B+ | B | B- | C+ | C | C- | D 433 4.00 3.67 3.33 3.00 2.67 2.33 2.00 1.67 1.00 0.00

  • Java Description You are given the task of reading a student’s name, semester letter grades, and...

    Java Description You are given the task of reading a student’s name, semester letter grades, and semester hours attempted from one file; calculating the semester GPA; and writing the student’s name and semester GPA to another file. GPA Calculation GPA = Total Quality Points / Hours Attempted Quality Points for each class = Grade Conversion Points * Hours Attempted The letter grades with corresponding point conversions is based upon the following table: Letter Grade Conversion Points A 4 points B...

  • Using Java, write a program that teachers can use to enter and calculate grades of individual...

    Using Java, write a program that teachers can use to enter and calculate grades of individual students by utilizing an array, Scanner object, casting, and the print method. First, let the user choose the size for the integer array by using a Scanner object. The integer array will hold individual assignment grades of a fictional student. Next, use a loop to populate the integer array with individual grades. Make sure each individual grade entered by the user fills just one...

  • in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a...

    in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a program that asks the user for an input file name, open, read ar number of students is not known. For each student there is a name and and display a letter grade for each student and the average test score fc • openFile: This method open and test the file, if file is not found and exit. Otherwise, return the opened file to the...

  • /** * File: GradeCalculator . java * Description: Instances of this class are used to calculate...

    /** * File: GradeCalculator . java * Description: Instances of this class are used to calculate * a course average and a letter grade. In order to calculate * the average and the letter grade, a GradeCalculator must store * two essential pieces of data: the number of grades and the sum * of the grades. Therefore these are declared as object properties * (instance variables). * Each time calcAverage (grade) is called, a new grade is added to *...

  • Write a Java program, including comments, to compute statistics for how students did on an exam....

    Write a Java program, including comments, to compute statistics for how students did on an exam. The program should compute various things about a student and print it all out. Then it repeats the process for each new student until the entire set of data has been completed. (a) The program reads in and prints the ID number of a student [see step (g) below] and then the number of right answers and the number of wrong answers. (The total...

  • Write a program in C language that reads scores and id numbers from a file, finds...

    Write a program in C language that reads scores and id numbers from a file, finds the average score, and assigns each student a grade based on the following rules: Each score > average + 20 gets an A Each score between average + 10 and average + 20 gets a B Each score between average - 10 and average + 10 gets a C Each score between average - 20 and average - 10 gets a D Each score...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT