Your English instructor, realizing you are a programmer, asks you to write a Gra
ID: 3636983 • Letter: Y
Question
Your English instructor, realizing you are a programmer, asks you to write a Grade Book program for his class to help him compute final grades. Design a program that asks for the student’s name and four test grades. You are to display the student’s name, four test grades, the average of the four test grades and the final letter grade the student earned in the course.Your English instructor gives you the following grading scale:
95-100 A+
90-94 A-
85-89 B+
80-84 B-
75-79 C+
70-74 C-
65-69 D+
60-64 D-
59 or below F
You are to submit, as a Microsoft Word Document, the following for this assignment:
1. Pseudocode
2. Flowchart
Remember to follow the guidelines of good program design. Make sure to use meaningful variable names and thoroughly comment each line of your code. You may only use techniques learned in Modules One and Two.
Explanation / Answer
Very generic pseudo code:
Read Sname,grade1, grade2,grade3,grade4
Compute avg_grade=(grade1+grade2+grade3+grade4)/2
If avg_grade between 95 and100 Then lgrade=A+
Else If avg_grade between 90 and 94 Then lgrade=A-
Else If avg_grade between 85 and 89 Then lgrade=B+
Else If avg_grade between 80 and 84 Then lgrade=B-
Else If avg_grade between 75 and 79 Then lgrade=C+
Else If avg_grade between 70 and 74 Then lgrade=C-
Else If avg_grade between 65 and 69 Then lgrade=D+
Else If avg_grade between 60 and 64 Then lgrade=D-
Else lgrade=F
Write sname,grade1,grade2,grade3,grade4,avg_grade,lgrade
More detailed Pseudo Code:
Function ComputeGrade ()
{
/* Declare variables needed to save input values for student name and 4 grades*/
sname char(50)
grade1 decimal
grade2 decimal
grade3 decimal
grade4 decimal
avg_grade decimal
lgrade char(7)
/* Initialize the variables */
sname =Null
grade1 =0
grade2 =0
grade3 =0
grade4 =0
avg_grade =0
lgrade =Null
/* Accept the input values into the variables*/
Print "Enter Student name: "
Read sname
Print "Enter grade 1"
Read grade1
Print "Enter grade 2"
Read grade2
Print "Enter grade 3"
Read grade 3
Print "Enter grade 4"
Read grade 4;
/* Calculate the average grade and assign it to avg_grade */
avg_grade = (grade1+grade2+grade3+grade4)/4
/* Check the grading scale to come up with a grade letter */
Case avg_grade
when <= 59 Then lgrade='F'
Else when >=95 and <=100 Then lgrade= 'A+'
Else when >=90 and <=94 Then lgrade='A-'
Else when >=85 and <=89 Then lgrade='B+'
Else when >=80 and <=84 Then lgrade='B-'
Else when >=75 and <=79 Then lgrade='C+'
Else when >=70 and <=74 Then lgrade='C-'
Else when >=65 and <=69 Then lgrade='D+'
Else when >=60 and <=64 Then lgrade='D-'
Else lgrade='Unknown'
end case
/* Display the output */
Print " Student Name =" &sname
Print "Grade 1=" &grade1
Print "Grade 2=" &grade2
Print "Grade 3=" &grade3
Print "Grade 4=" &grade4
Print "Average Grade=" &avg_grade
Print "Letter grade=" &lgrade
}
I don't have MS word on my machine, so I cannot add the diagram but I can put it in words so you get an idea.
Use terminator stage for start
Connect the start stage to a parallelogram that says "read sname,grade1,grade2,grade3,grade4"
Connect parallelogram to a rectangle where you calculate the average. Put the formula in it.
Connect this parallelogram to a diamond shape where the decision is made (if avg between 95 and 100). This stage will have 2 links going out. One link should say Yes and Other should say No. The yes link will be connected to a rectangle where lgrade is assigned A+. The 'No' link will be connected to another diamond where the condition is checked (if avg between 90 and 94). Yes link from this is to a rectangle where lgrade is assigned A-. The No link will be connected to another diamond where the condition is checked (if avg between 85 and 90). and so on and so forth. Finally, links out of all the rectangles where the lgrade is assgined a values connect to a parallelogram which says "Write sname,grade1,grade2,grade3,grade4,avg_grade,lgrade". Connect this parallelogram to a stop stage.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.