• 0

Pseudocode and VB


Question

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

  • 0

That's not VB?

In VB6, pseudocode was an alternate way of compiling code into apps. It didn't actually compile anything into native code but instead it made a program that still needed to be interpreted by the VB runtime.

Link to comment
Share on other sites

  • 0

Right... that's why it's Pseudocode. You write your program in this, more plain language way before proceeding to the more taxing coding, which refines the code further into something VB likes. What you see is not VB neccesarily. I could apply that to C++ or antoher language if I felt like it.

My question is, is this pseudocode right? I'm walking a thin line between being too coded and having too much natural language. The example that I have mixes the two, so I'm confused.

Link to comment
Share on other sites

  • 0

That's correct psuedocode syntax, or grammar, there really isn't REAL REAL syntax for psuedocode, however as long as you get the general structure correct, like BEGIN ProgramName, END ProgramName, the general control structures, IF THEN, CASEWHERE, PRINT, and a few others... And also if you want to call a different program remember to underline it, so that you indicate that it's a call.

Otherwise most of the statements inside the psuedocode is plain english.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.