Lesson 4, Introduction to Problem Solving
Part 2c

You have been asked by your instructor to write a computer program that will figure out what a student's course average will be at the end of the course.  The assignment average will be 50% of their grade.  Exam 1 and Exam 2 grades are both 15% of their grade.  The final exam grade is 20% of their grade. They want you to tell them what the course average is.

Provide me with:

1.  Assumptions:
2.  Input
3.  Calculations:
4.  Output

Scroll down for the answer after you try to do it yourself first

 

 

 

 

 

 

 

 

 

 

 

 

Assumptions:
Weight of scores is constant for regular and advanced classes
Only 4 scores will be provided
One student's scores will be presented at a time
The average of the assignments will not be calculated in the program
assignment weight = .50
exam 1 weight = .15
exam 2 weight = .15
final exam weight = .20
 

Input:
a.  Assignment Average
b.  Exam 1 score
c.  Exam 2 score
d.  Final Exam Score
 

Calculations:

    a.  AssignWt = Assignment Average *assignment weight
    b.  Exam1Wt = Exam 1 score * exam 1 weight
    c.  Exam2Wt = Exam 2 score * exam 1 weight
    d.  FinalExamWt = Final Exam score * final exam weight
    e. FinalAverage = AssignWt + Exam1Wt + Exam2Wt + FinalExamWt

Output:
    a.   Output:  "Your Final Average is " FinalAverage
   

Now you need to write the Human Algorithm (step by step how would you come up with the final output:

Scroll down for the answer after you try to do it yourself first

 

 

 

 

 

 

 

 

 

 

Human Algorithm:

Remember, we create the human algorithm from the problem statement (although we can go the other way if you find that creating the human algorithm is easier.  We start out by declaring our constants (1-4), inputting our data (5-8), doing the math (9-13) then outputting the answer (14)


1.  regular assignment weight = .50
2.  regular exam 1 weight = .15
3.  regular exam 2 weight = .15
4.  regular final exam weight = .20


5.  Input:  Assignment Average
6.  Input:  Exam 1 score
7.  Input:  Exam 2 score
8.  Input:  Final Exam Score


9.      AssignWt = Assignment Average * regular assignment weight
10.      Exam1Wt = Exam 1 score * regular exam 1 weight
11.      Exam2Wt = Exam 2 score * regular exam 1 weight
12.      FinalExamWt = Final Exam score * regular final exam weight
13.  FinalAverage = AssignWt + Exam1Wt + Exam2Wt + FinalExamWt
 

14.  Output:  "Your Final Average is " FinalAverage

Assumptions:
assignment weight = .50
exam 1 weight = .15
exam 2 weight = .15
final exam weight = .20

Input:
a.  Assignment Average
b.  Exam 1 score
c.  Exam 2 score
d.  Final Exam Score

Calculations:
    a.  AssignWt = Assignment Average *assignment weight
    b.  Exam1Wt = Exam 1 score * exam 1 weight
    c.  Exam2Wt = Exam 2 score * exam 1 weight
    d.  FinalExamWt = Final Exam score * final exam weight
    e. FinalAverage = AssignWt + Exam1Wt + Exam2Wt + FinalExamWt

Output:
    a.   Output:  "Your Final Average is " FinalAverage

 

 

 

Now we need to flowchart this Human Algorithm.  Remember each step is a different flowchart symbol.  Don't combine steps.

Scroll down for the answer after you try to do it yourself first

 

 

 

 

 

 

 

 

 

 

 

Flowchart:

Remember we create the flow chart directly from the human algorithm.  14 steps in the human algorithm, 14 symbols on the flowchart.  If you open your human algorithm and visual logic together on the same screen, next to each other, the flowchart should be easy to create since we have already solved the problem.

Human algorithm

1.  regular assignment weight = .50
2.  regular exam 1 weight = .15
 

3.  regular exam 2 weight = .15
4.  regular final exam weight = .20

5.  Input:  Assignment Average
6.  Input:  Exam 1 score
 

7.  Input:  Exam 2 score
 

8.  Input:  Final Exam Score

9.      AssignWt = Assignment Average * regular assignment weight
 

10.      Exam1Wt = Exam 1 score * regular exam 1 weight
 

11.      Exam2Wt = Exam 2 score * regular exam 1 weight
 

12.      FinalExamWt = Final Exam score * regular final exam weight
 

13.  FinalAverage = AssignWt + Exam1Wt + Exam2Wt + FinalExamWt
 

14.  Output:  "Your Final Average is " FinalAverage

 

 

 

 

Next you want to write the code using html Kit.

Scroll down for the answer after you try to do it yourself first

 

 

 

 

 

 

 

 

 

VBCode

We can not have any spaces in our variable (places in memory) names.  You can not use any of the Microsoft reserve words either.  You can find list of them at http://support.microsoft.com/kb/216528 You will know you have used a reserve word as a place in memory when using html kit because it will turn purple when you type it into the DIM line.  Try it by typing "Date" as a place in memory and you will see it is a different color than the other words you have typed.

We type the code directly from the flowchart since we have already solved the problem.  Each symbol is a line of code.  We get the DIM values from each assignment (rectangle) and each input.  Then we just type the line of code the symbol represents.  Assignments are already in vbscript syntax, for input you just add (inputbox(...)), for output you add (document.write....)

 

Visual Basic Script

<script language=vbscript>
Option Explicit
DIM regularassignwt, regularexam1wt, regularexam2wt, regularfinalwt
DIM assignavg, exam1, exam2, finalexam, classtype
DIM assignwt, exam1wt, exam2wt, finalexamwt, finalaverage


'assignments
regularassignwt = .50
regularexam1wt = .15
regularexam2wt = .15
regularfinalwt = .20

'input
assignavg = inputbox("What is the assignment average?")
exam1 = inputbox("What is the exam 1 score?")
exam2 = inputbox("What is the exam 2 score?")
finalexam = inputbox("What is the final exam score?")
classtype = inputbox("What is classtype? regular/advanced")

 

 

'calculations
assignwt = assignAvg * regularassignwt
exam1wt = exam1 * regularexam1wt
exam2wt = exam2 * regularexam2wt
finalexamwt = finalexam * regularfinalwt
FinalAverage = assignwt + exam1wt + exam2wt + finalexamwt

' output
document.write "<br>Your final average is " & finalaverage

</script>

 

Flowchart

 

 

.