I have to write a pseudocode based on a flow chart for my Intro to VB class (read, more like, Intro to Programming).
The books I have aren't very clear on how to write Pseudocode. I have a couple of examples which I used as reference, as well as a corrected flowchart as a basis.
My biggest question is does this look right? There are parts where I put in more natural language and others where I put the equation as it might look in VB. I think the logic is alright (like I said, it's based on the corrected flowchart).
Question
deck
I have to write a pseudocode based on a flow chart for my Intro to VB class (read, more like, Intro to Programming).
The books I have aren't very clear on how to write Pseudocode. I have a couple of examples which I used as reference, as well as a corrected flowchart as a basis.
My biggest question is does this look right? There are parts where I put in more natural language and others where I put the equation as it might look in VB. I think the logic is alright (like I said, it's based on the corrected flowchart).
So, without further something;
BEGIN PROGRAM
TotalStudents = 0
TotalA = 0
TotalB = 0
TotalC = 0
TotalF = 0
ClassAverage = 0
AverageGrade = 0
TotalAverageGrade = 0
LetterGrade
PRINT Headings
READ StudentID, StudentName, Exam1, Exam2, Exam3
DO WHILE StudentName <> ?END?
ADD 1 To TotalStudents
AverageGrade = (Exam1 + Exam1 + Exam3) / 3
ADD AverageGrade To TotalAverageGrade
IF AverageGrade < 60 THEN
LetterGrade = ?F?
ADD 1 To TotalF
ELSE
IF AverageGrade < 70 THEN
LetterGrade = ?D?
ADD 1 To TotalD
ELSE
IF AverageGrade < 80 THEN
LetterGrade = ?C?
ADD 1 To TotalC
ELSE
IF AverageGrade < 90 THEN
LetterGrade = ?B?
ADD 1 To TotalB
ELSE
LetterGrade = ?A?
ADD 1 To TotalA
END IF
PRINT StudentID, StudentName, AverageGrade, LetterGrade
READ StudentID, StudentName, Exam1, Exam2, Exam3
END DO
ClassAverage = TotalAverageGrade / TotalStudents
PRINT TotalStudents, TotalA, TotalB, TotalC, TotalD, TotalF, ClassAverage
END PROGRAM
Thanks,
~D
Link to comment
Share on other sites
4 answers to this question
Recommended Posts