Explore BrainMass
Share

# Analyze Pseudocode

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

The following are a few examples of pseudocode:

>> Example 1

start

if Quantity > 100 then

Discount = 20

else

if Quantity > 12 then

Discount = 10

endif

endif

Total = Price* Quantity
Total = Total - (Discount* Total)/100
Print Total

Stop

>> Example 2

Start

Pass = 0
Fail = 0
Total = 0
X = 0
while (End Of Student_Marks_File) do

Total = Total + Subject_Marks

if (Subject_Marks > 40) then

Print "Student passed in" Subject

else

Print "Student failed in" Subject

endif
X = X +1

endwhile
Average = Total/X
Print "Average Marks of" Student_Name "are" Average

Stop

From the above examples of pseudocode containing control structures, analyze the logic implemented in the pseudocode.

https://brainmass.com/computer-science/pseudocode/analyze-pseudocode-457633

#### Solution Preview

First, some basic definition taken from http://www.cs.cornell.edu/Courses/cs482/2003su/handouts/pseudocode.pdf

"Algorithms will often be expressed in pseudocode, a mixture of code and English ... Pseudocode strikes a sometimes precarious balance between the understandability and informality of English and the precision of code."

(it's worth reading the whole PDF by the way).

Keep in mind that unlike a programming language where there's a defined syntax, no 'standard' way exists in writing pseudocode. The key point to keep in mind when writing one is clarity and readability while being able to convey the essence of the algorithm outlined.

That said, the following is the analysis of pseudocode in example 1:

1. (Stating the obvious) It can be seen that a pseudocode block is enclosed within the start and stop commands.
2. The next block of the algorithm

performs reading of some "Customer_Order_Record" from somewhere. Notice here that the pseudocode is kept high-level and does not specify the exact mechanism of how to perform this reading and from where. The input could be read, for instance, from some IO stream off the disk or input typed by the user from the console or some data streamed from the network. The specific details are left out for implementation.

3. The next conditional statement

if Quantity > 100 then

Discount = 20 ...

#### Solution Summary

The solution analyzes pseudocodes.

\$2.19

## Computer Science Programming Problem

Provide the analysis and pseudo code only (no diagrams are required).
- Display Contents of Grade File

For each of the following problems, use the top-down modular approach and pseudocode to design a suitable program to solve it.

1. Input names of students from the user, terminated by ZZZ, and create a data file GRADES with records of the form:
student (string), test1 (integer), test2 (integer), test3 (integer) In this file, all test scores should be set equal to 0.

IPO Analysis

2. Display the contents of the file GRADES created in Problem 1. Each student's record should appear on a separate line and include the total score (the sum of the three tests) for that student.

IPO Analysis

For example, a line of output might be: R. Abrams 76 84 82 242

View Full Posting Details