Ask Question

Create a function named calculate_gpa that is given a grade_scale and a student (in that order). It calculates the overall gpa for that student. The student will be in the same format as the example student123 student.

+5
Answers (1)
  1. 14 March, 20:15
    0
    import java. util. ArrayList;

    import java. util. Scanner;

    public class StudentGrade {

    public static void main (String[] args) {

    Scanner scan = new Scanner (System. in);

    ArrayList nameList = new ArrayList ();

    double scores[][] = new double[5][4];

    for (int i=0; i
    System. out. println ("Enter Student " + (i+1) + " Name: ");

    nameList. add (scan. nextLine ());

    System. out. println ("Enter Student " + (i+1) + " scores: ");

    for (int j=0; j
    scores[i][j] = scan. nextDouble ();

    }

    scan. nextLine ();

    }

    for (int i=0; i
    System. out. println ("Student " + (i+1) + " Information: ");

    System. out. println ("Student Name: "+getName (i, nameList));

    double average = getAverage (scores, i);

    System. out. println ("Student Average: "+average);

    System. out. println ("Student Grade: "+getGrade (average));

    }

    }

    public static char getGrade (double average) {

    char grades[] = {'A','B','C','D','F'};

    if (average >=90 && average<=100) {

    return grades[0];

    }

    else if (average >=80 && average<90) {

    return grades[1];

    }

    else if (average >=70 && average<80) {

    return grades[2];

    }

    else if (average >=60 && average<70) {

    return grades[3];

    }

    else {

    return grades[4];

    }

    }

    public static double getAverage (double scores[][], int index) {

    double average = 0;

    double sum = 0;

    for (int i=0; i
    sum = sum + scores[index][i];

    }

    average = sum / 4;

    return average;

    }

    public static String getName (int index, ArrayList namelist) {

    return namelist. get (index);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Create a function named calculate_gpa that is given a grade_scale and a student (in that order). It calculates the overall gpa for that ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers