Question

Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...

Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and letterGrade.

The user will type a line of input containing the student's name, then a number that represents the number of scores, followed by that many integer scores (user input is in bold below). The data type used for the input should be one of the primitive integer data types. Here are two example dialogues:

Enter a student record: Maria 5 72 91 84 89 78

Maria's grade is 82.8.

Maria's final letter grade is B.

Enter a student record: Jordan 4 86 71 62 90

Jordan's grade is 77.25. Jordan’s final letter grade is C.

The method gradeAverage accepts a Scanner for the console parameter and then calculates and returns the student's grade point average. The method letterGrade takes one parameter, the students grade point average and then computes and returns the students final letter grade. The students final letter grade is based on the following table:

Grade Point Average

Letter Grade

90–100

A

80–89

B

70–79

C

60–69

D

Below 60

F

gradeAverage and letterGrade should not contain any System.out.print statements. The output should be formatted so the average does not contain more than 2 decimal places.

If you would like to earn bonus points, throw out the lowest score when computing average. For example, Jordan’s final average would be:

Jordan's grade is 82.33 because the students average of (86 + 71 + 90) / 3 equals 82.33. Jordan’s lowest score was 62 and was thrown out.

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

Please find the answer below:::

PrintGPA.java

package classes10;

import java.util.Scanner;

public class PrintGPA {


   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);
       System.out.print("Enter a student record : ");
       String name = sc.next();
       double gradePoint=gradeAverage(sc);
       char grade = letterGrade(gradePoint);
      
       System.out.printf("%s's grade is %.2f\n",name,gradePoint);
       System.out.printf("%s's final letter grade is %c\n",name,grade);
      
   }

   private static char letterGrade(double gradePoint) {
       if(gradePoint>=90 && gradePoint<=100){
           return 'A';
       }else if(gradePoint>=80){
           return 'B';
       }else if(gradePoint>=70){
           return 'C';
       }else if(gradePoint>=60){
           return 'D';
       }else{
           return 'F';
       }
   }

   private static double gradeAverage(Scanner sc) {
       int record = sc.nextInt();
       int mark;
       double total = 0;
       int min = 99999;
       for(int i=0;i<record;i++){
           mark = sc.nextInt();
           if(mark<min){
               min = mark;
           }
           total+=mark;
       }
       //remove minimum
       total -=min;
       //return average
       return total/(record-1);
   }

}

output:

Add a comment
Know the answer?
Add Answer to:
Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...
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
  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • Test Scores and Grade Write a program that has variables to hold three test scores. The...

    Test Scores and Grade Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table: Test Score Average Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60...

  • Write a grading program for the following grading policies:- a. There are two quizzes, each graded...

    Write a grading program for the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:- >90 A >=80 and <90 B...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • Could someone show how to do this in C#? I keep getting errors for mine and...

    Could someone show how to do this in C#? I keep getting errors for mine and the other answers on here that are similar doesn't work. And please make sure it accepts user input. Write the class "Tests". Ensure that it stores a student's first name, last name, all five test scores, the average of those 5 tests' scores and their final letter grade. (Use an array to store test scores.) Add constructors and methods to manipulate the data stored...

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