CPSC 231: Assignment 2 (Due Monday Oct. 7)

Weighting = 3%, 16 marks total

Grade out of 16

Letter
16 A+
15.5 A
15 A-
14.5 B+
14 B
13.5 B-
13 C+
12.5 C
12 C-
11.5 D+
11 D
10.5 D-
Less than 10.5 F
 

Assignment 2, Part 1: Specifying algorithms with a flowchart (4 marks)

For the following problem, design an algorithm and express it using a flowchart. An input list contains data for the dimensions
of two-dimensional objects:

For example, your algorithm may have to handle the data for the following list:  -1  55  -3  15.0  10.0  -2  5  7.5  -1  33.6 -4.  Calculate and output the area for each object in such a list.  The list can be arbitrarily long.  You will be responsible for looking up the formulas that are needed (if you are unsure of where to start looking try www.google.com).   You can assume that there are no error conditions (e.g., if you receive the code for a circle you can assume that it will be followed by only one number for the diameter before the next code will be encountered).

Assignment 2, Part 2: Specifying algorithms with pseudo-code (4 marks)

You must specify the algorithm described in Part 1 using pseudo-code rather than using a flowchart.

Assignment 2, Part 3: Fixing a broken program (4 marks)

In the assignment 2 directory (under /home/231/assignments/assignment2) you will find a Pascal program called "broken" in a Unix text file called "broken.p".  Rename the name of the file to "fixed.p" and the rename the program to "fixed".  Then fix all of the syntax errors in the program so that it will compile.  Aside from making changes that will allow the program to compile you cannot otherwise change the program (i.e., you can't just simply write your own Pascal program instead of using the one that was provided).

Four marks will be given only for a program that will compile, zero marks will be given otherwise (because it is crucial that you learn early on how to write a Pascal program that is free of syntax errors). 

Learning objectives:

Getting familiar with some of the more common syntax errors that prevent program your program from compiling.  The ultimate goal is to be able to produce a program free of these errors. 

Assignment 2, Part 4: Simple text formatting (4 marks)

In the assignment 2 directory (under /home/231/assignments/assignment2) you will find a Pascal program called "formatting.p".  You are to change this program so that the output matches the output of the executable program called "formattingSolution".  The specific changes required include:

Learning objectives

Producing simple formatted output in Pascal.