Student GPA Calculator – Repetition Statements 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 ±nal grades. ²he program should output the Student name along with the GPA. 

Student GPA Calculator – Repetition Statements Homework



²here are 5 components of your submission including: Program DescripTon- A detailed, clear descripTon 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 de±niTons. Be sure to describe the necessary formulas and sample calculaTons that might be needed. ²alk about how your design will allow any number of students and ±nal grades to be possible inputs. ²est plan - Prepare at least 1 set of input data (²est data) along with their expected output for tesTng your program. ²his 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 – Provide a ³owchart for your design. You can use Word, Powerpoint, Visio or any so´ware you have available that will allow to draw shapes and connectors. Pseudocode- Provide pseudocode of your overall design that ful±lls the requirements of the project All of these components should be placed in word document for submission. AddiTonal details about the program you need to write: 1. GPA is calculated by summing the point equivalents for ±nal grades and taking the average. A =4, B=3, C=2, D=1, and F = 0. So, if someone earned 2 A’s and 1 B, their GPA would be (4 + 4 + 3)/3 = 3.67 2. ²hink about using a simple process to stop entering students and course grades. For example, if StudentName < 0.

Background image of page 1

Example applicaton TesT daTa: ±esT Case # InpuT ExpecTed OuTpuT 1 Sally: A,D,B,C John: A,A,A,B,B Jason: A,A,A,A,B Bob: B,B Bill: A GPA for Sally is : 2.5 GPA for John is: 3.6 GPA for Jason is: 3.8 GPA for Bob is: 3.0 GPA for Bill is: 4.0
Background image of page 2


The answer


1. Program Description

This program allows the user to enter any number of students, and for each student, any number of course final grades (A, B, C, D, F). For each student, the program calculates their Grade Point Average (GPA) based on the grades entered, using the standard scale: A=4, B=3, C=2, D=1, F=0. The program then outputs each student’s name with their calculated GPA. Input is repeated for students and grades until the user signals they are finished (e.g., entering a blank or special value for name).


2. Analysis

Inputs:

  • Student names (string)

  • Course final grades for each student (A, B, C, D, F; repeated for each course)

Outputs:

  • For each student: Student name and calculated GPA (rounded to 2 decimals)

Process:

  • The program must be able to accept any number of students, and for each student, any number of grades.

  • Grades are converted to points using:

    • A = 4

    • B = 3

    • C = 2

    • D = 1

    • F = 0

  • GPA = (Sum of grade points) / (Number of grades)

  • A loop is used to collect grades for each student, and a loop is used to collect students.

Variables:

  • student_name: string (name of student, empty or special value to quit)

  • grade: string (one letter: A, B, C, D, F)

  • grades: list (to store all grades for a student)

  • total_points: int/float (sum of grade points for a student)

  • num_grades: int (number of grades entered for a student)

  • GPA: float (calculated GPA for the student)

Input Validation:

  • Only accept valid grades (A, B, C, D, F)

  • Student name cannot be blank unless ending input

Formula & Sample Calculation:

  • Example: John has grades [A, A, A, B, B]
    Points = [4, 4, 4, 3, 3]
    GPA = (4+4+4+3+3)/5 = 18/5 = 3.6

Flexibility:

  • Using loops allows any number of students and grades.


3. Test Plan

Test Data Table

Student NameGrades EnteredExpected GPA
SallyA, D, B, C2.5
JohnA, A, A, B, B3.6
JasonA, A, A, A, B3.8
BobB, B3.0
BillA4.0
EmmaF, F, D0.33
LisaC, B, A, A3.25
TomD, C, F1.0
MaryA, B, A3.67
MaxC, C, B, D, F, A2.0

Test case demonstrates various numbers of grades and GPA calculations.


4. Flowchart

(Textual Representation – Draw this using Word, PowerPoint, or any diagram tool)



+-----------------------------------+ | Start | +-----------------------------------+ | v +------------------------------+ | Input student name | | (blank to finish) | +------------------------------+ | | not blank blank | v | +----------------+ | | End | | +----------------+ v +------------------------------+ | Initialize grades list | +------------------------------+ | v +------------------------------+ | Input grade (A,B,C,D,F, | | blank to finish for student) | +------------------------------+ | v +------------------------------+ | Is grade valid? | +------------------------------+ | | Yes No | v | +--------------------+ | | Prompt again | | +--------------------+ v +-------------------------------+ | Add grade to list | +-------------------------------+ | v +------------------------------+ | More grades for this student?| +------------------------------+ | | Yes No | v | +-----------------------------+ | | Calculate GPA = sum(points) | | | / len(grades) | | +-----------------------------+ | | | v | +-----------------------------+ | | Output student & GPA | | +-----------------------------+ v [Back to input grade]

5. Pseudocode


START WHILE True Prompt user to enter student name (blank to finish) IF name is blank BREAK grades_list = empty list WHILE True Prompt user to enter final grade for this student (A,B,C,D,F, blank to finish) IF grade is blank BREAK IF grade not in [A,B,C,D,F] Print "Invalid grade, try again." CONTINUE Add grade to grades_list IF grades_list is not empty total_points = 0 FOR each grade in grades_list IF grade == A: total_points += 4 ELSE IF grade == B: total_points += 3 ELSE IF grade == C: total_points += 2 ELSE IF grade == D: total_points += 1 ELSE IF grade == F: total_points += 0 GPA = total_points / number of grades in grades_list Output: "GPA for [student_name] is: [GPA rounded to 2 decimals]" ELSE Output: "No grades entered for [student_name]" END

6. Example Python Implementation (For Reference/Testing):

python

grade_points = {'A': 4, 'B': 3, 'C': 2, 'D': 1, 'F': 0} while True: name = input("Enter student name (blank to finish): ") if name == "": break grades = [] while True: grade = input(f"Enter final grade for {name} (A,B,C,D,F) [blank to finish]: ").upper() if grade == "": break if grade not in grade_points: print("Invalid grade. Enter A, B, C, D, or F.") continue grades.append(grade) if grades: gpa = sum(grade_points[g] for g in grades) / len(grades) print(f"GPA for {name} is: {gpa:.2f}") else: print(f"No grades entered for {name}")

Place each section into your Word document as requested, and draw the flowchart with your preferred tool.
If you need a PDF version or images of the flowchart, let me know!


📩 Need a similar solution? Email me: adel455@hotmail.com


Previous Post Next Post

Comments

Nepali Graphics - Learn design, Animation, and Progrmming