Lesson Seven, Part 3, Test Score Average problem.

You have been asked to write a program will be used throughout a school.  They want students to be able to keep track of their grade point average for their individual classes.  They want the program to take in as many grades as the student has at the moment and then output the course average after each grade as a popup message.  When they are done entering their grades have an output that will allow the student to print out their current GPA but not the individual scores. All scores have the same weight.

First Let's do the problem statement for this:
Assumptions
Input
Calculations
Output
Answer

 

 

 

 

 

 

 

 

Problem Statement
Assumptions:
1. An infinite number of grades can be entered
2. All grades have the same weight 

Given:
1.  Grades
2.  Whether they have another grade to add

Calculations
1.  totalgrades = Initial grade + new grade
2.  number of grades = number of grades + 1
3.  Grade Average = total grades / number of grades


Output:
running average (message box)
Final Average

Now write the human Algorithm  Answer

 

 

 

 

 

Human Algorithm:
1.  Input "would you like to enter a grade?" If No go to line 7
2. Input "What is the grade?"
3. Grade Total = Add grade to existing grades
4. GPA = Divide the total grades by the number of grades
5. Output (popup) your grade point average is "GPA"
6.  Go to line 1
7.  output "Your GPA is "GPA"
 


Now Create the flowchart   Answer

 

 

 

 

 

 

 

 

Flow Chart:


Now Create the VB Script   Answer

 

 

 

 

 

<Script language ="vbscript">
Dim EnterGrade, grade, GradeTotal, NumGrades, courseaverage

EnterGrade = Inputbox("Would you like to enter a grade? yes/no")

Do While EnterGrade = "yes"
    grade = Inputbox("What is the grade?")
    GradeTotal = GradeTotal + Cint(grade)
    NumGrades = NumGrades + 1
    courseaverage = GradeTotal/NumGrades '<--This line is here because we need to do that math to output                                                        
                                                                     '<--the messagebox. If we didn't do that it should be after "Loop"
    MsgBox("Your course average is " & courseaverage)
    EnterGrade = Inputbox("Would you like to enter a grade? yes/no")
Loop
Document.write "Your course average is " & courseaverage
</Script>