Question

In this homework, you will design a program to perform the following task: Write a program...

In this homework, you will design a program to perform the following task:

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed. Design your program to calculate the Grade Point Average (GPA) for each student based on each of their final grades. The program should output the Student name along with the GPA.

There are 5 components of your submission including:

Program Description- A detailed, clear description of the program you are building.

Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about how your design will allow any number of students and final grades to be possible inputs.

Test plan - Prepare at least 1 set of input data (Test data) along with their expected output for testing your program. This test case should include at least 10 students. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)

Flowchart

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

Program Code:

//import the util package to

//use the Scanner class

import java.util.*;

//StudentGPAImplementation class that will read the student name

//and grades of the courses.

//Displays the respective course grades and their GPA's

public class StudentGPAImplementation

{

     //main method

     public static void main(String args[])

     {

          //Object to the Scanner class to read input

          Scanner in=new Scanner(System.in);

          //to add the array of grades values

          ArrayList<ArrayList<Character>> studScoreGrades=new ArrayList<ArrayList<Character>>();

          //to add the array of student names

          ArrayList<String> studNames=new ArrayList<String>();

          //count variables

          int count=0;

          int incre=0;

          //to store each student GPA's

          double averageGrades[];

          //one choice to add students

          //one choice to add grades

          char choice='Y';

          char ch='y';

         

          //the loop contains the logic to add the student

          //and their respective details.

          do

          {

              incre++;

              //prompt the user to enter the name of the student

              System.out.println("Enter name of the student "+(incre)+": ");

              studNames.add(in.next());

              //create a character arraylist to store the grades of

              //each student

              ArrayList<Character> grades=new ArrayList<Character>();

              count=0;

             

              //logic to read the grades of the courses

              do

              {                 

                   System.out.println("Enter the grade of course "+(count+1)+": ");

                   grades.add(in.next().charAt(0));

                   System.out.println("Would like to add more grades? Press Y or y to continue.");

                   ch=in.next().charAt(0);

                   count++;

              }while(ch=='y'||ch=='Y');

              //add the arraylist of grades to the studScroreGrades.

              studScoreGrades.add(grades);

              System.out.println("Would like to add more students? Press N or n to discontinue.");

              choice=in.next().charAt(0);

          }while(choice=='Y' || choice=='y');

         

         

          int length;

          length=studScoreGrades.size();

          averageGrades=new double[length];

         

          //logic to compute the each individual average GPA's of the

          //students

          for(int i=0;i<studScoreGrades.size();i++)

          {            

              averageGrades[i]=computeAverage(studScoreGrades.get(i));

          }

         

          //print the output

          System.out.println("\n\nThe GPA's of the students are: ");

          for(int i=0;i<studNames.size();i++)

          {

              System.out.println("Student Name: "+studNames.get(i));

              System.out.print("Grades are: ");

              displayGPAs(studScoreGrades.get(i));

              System.out.println("GPA: "+ averageGrades[i]);

          }

     }

    

     //static method to compute the Average GPA's and this

     //method returns double

     public static double computeAverage(ArrayList<Character> grade)

     {

          //to keep the count of number of times, the grades are assigned

          int count[]=new int[5];

          int gradeA=0;

          int gradeB=0;

          int gradeC=0;

          int gradeD=0;

          int gradeF=0;

          //logic to find the number of times the student

          //has scored the same grade in over all courses

          for(int i=0;i<grade.size();i++)

          {

              if(grade.get(i)=='A')

              {

                   count[0]++;

                   gradeA+=4;

              }

              else if(grade.get(i)=='B')

              {

                   count[1]++;

                   gradeB+=3;

              }

              else if(grade.get(i)=='C')

              {

                   count[2]++;

                   gradeC+=2;

              }

              else if(grade.get(i)=='D')

              {

                   count[3]++;

                   gradeD+=1;

              }

              else if(grade.get(i)=='F')

              {

                   count[4]++;

                   gradeF+=0;

              }

          }

          int total=0;

          double average=0;

          //logic to find the total number of courses

          for(int i=0;i<count.length;i++)

          {

              total+=count[i];

          }

          //logic to compute the GPA

          average=(gradeA+gradeB+gradeC+gradeD+gradeF)/(total*1.00);

         

          //return the value

          return average;

     }

     //displayGPAs will display the grades of the each individual

     //student

     public static void displayGPAs(ArrayList<Character> grade)

     {

          for(int i=0;i<grade.size();i++)

          {

              System.out.print("Course "+(i+1)+":"+grade.get(i)+" ");

          }

     }

}

Sample output:

Enter name of the student 1:

ALEX

Enter the grade of course 1:

A

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 2:

A

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 3:

A

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 4:

B

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 5:

B

Would like to add more grades? Press Y or y to continue.

N

Would like to add more students? Press N or n to discontinue.

Y

Enter name of the student 2:

RICHARD

Enter the grade of course 1:

B

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 2:

B

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 3:

C

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 4:

C

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 5:

D

Would like to add more grades? Press Y or y to continue.

N

Would like to add more students? Press N or n to discontinue.

Y

Enter name of the student 3:

PARKER

.

.
.

.

.

Enter name of the student 10:

DAVID

Enter the grade of course 1:

B

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 2:

B

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 3:

C

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 4:

C

Would like to add more grades? Press Y or y to continue.

Y

Enter the grade of course 5:

A

Would like to add more grades? Press Y or y to continue.

N

Would like to add more students? Press N or n to discontinue.

N

The GPA's of the students are:

Student Name: ALEX

Grades are: Course 1:A Course 2:A Course 3:A Course 4:B Course 5:B GPA: 3.6

Student Name: RICHARD

Grades are: Course 1:B Course 2:B Course 3:C Course 4:C Course 5:D GPA: 2.2

Student Name: PARKER

Grades are: Course 1:C Course 2:C Course 3:C Course 4:D Course 5:A GPA: 2.2

Student Name: WILLIAM

Grades are: Course 1:A Course 2:A Course 3:A Course 4:A Course 5:A GPA: 4.0

Student Name: URAIN

Grades are: Course 1:F Course 2:F Course 3:C Course 4:C Course 5:D GPA: 1.0

Student Name: LEE-GUEON

Grades are: Course 1:B Course 2:A Course 3:B Course 4:C Course 5:A GPA: 3.2

Student Name: ERIC

Grades are: Course 1:C Course 2:C Course 3:C Course 4:C Course 5:D GPA: 1.8

Student Name: XAVIER

Grades are: Course 1:D Course 2:D Course 3:D Course 4:C Course 5:B GPA: 1.6

Student Name: KEPLER

Grades are: Course 1:A Course 2:B Course 3:C Course 4:D Course 5:F GPA: 2.0

Student Name: DAVID

Grades are: Course 1:B Course 2:B Course 3:C Course 4:C Course 5:A GPA: 2.8

Add a comment
Know the answer?
Add Answer to:
In this homework, you will design a program to perform the following task: Write a program...
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
  • Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student...

    Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • For each problem, you must: Write a Python program Test, debug, and execute the Python program...

    For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...

  • IN C You will be creating a program to help a teacher calculate final grades for...

    IN C You will be creating a program to help a teacher calculate final grades for a class. The program will calculate a final letter grade base on a standard 90/80/70/60 scale. You will be taking input from a file that contains all of the names and grades of each student. You will find the average for each student and output each student's final letter grade. Your program should accept the filename from the command-line Add error checking to make...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • Homework description::::: Write JAVA program with following description. Sample output with code will be helful... A...

    Homework description::::: Write JAVA program with following description. Sample output with code will be helful... A compiler must examine tokens in a program and decide whether they are reserved words in the Java language, or identifiers defined by the user. Design a program that reads a Java program and makes a list of all the identifiers along with the number of occurrences of each identifier in the source code. To do this, you should make use of a dictionary. The...

  • Write a C++ program to implement this task. Students are registered in 3 courses in a...

    Write a C++ program to implement this task. Students are registered in 3 courses in a semester. To pass each course, students have to make a grade greater than or equal to 40. You have to write a program to determine if the student will pass or fail the semester, based on the following criteria: A student passes if all three courses are passed. Additionally, a student may pass if only one subject is failed, and the overall average grade...

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

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