Anne
Dawson: CSCI110A_HW2_FA04.htm
Last
updated: Friday 24th September 2004, 7:47 PT
This
document is subject to change without notice.
Please
report any errors or omissions in this document:
adawson@coquitlamcollege.com
Special instructions:
For this assignment you must work alone.
See schedule for due date.
Homework
2
Specification:
Calculation of hypotenuse, area and circumference of a right
angled triangle with proof of Pythagorean theorem.
Step 1
Study the following:
Let's build up squares on the sides of
a right triangle. Pythagoras' Theorem then claims that the sum of (the areas
of) two small squares equals (the area of) the large one. In algebraic terms, a2 +
b2 = c2 where c is the hypotenuse while a
and b are the sides of the triangle.

Figure 1.
The theorem is of fundamental importance in the Euclidean Geometry
where it serves as a basis for the definition of distance between two points.
The hypotenuse of a right triangle is side
c
(the longest of the three sides).
The circumference of the triangle is a
+ b + c.
The area of the triangle is (a * b) / 2.
Your program must accept values for a
+ b then calculate the following values of the triangle:
1. the hypotenuse
2. the
circumference
3. the area
In addition:
4. Your program
should also show that the sum of the areas of the two small
squares (see Figure 1) equals the area of the large square.
You must use a function for each of these calculations:
1. the hypotenuse (
the function receives a
+ b, calculates and returns c).
2. the
circumference (the function receives a + b + c and returns
the sum).
3. the area ( the function receives a
+ b, and returns (a * b) / 2).
You must use a general procedure for this calculation:
4. the procedure
receives a + b + c and calculates and prints out
the sum of the
areas
of the two small squares (see Figure 1) and the area of the large square.
Step 2
Design an algorithm (the steps to solve the problem). You should
have the algorithm approved by your instructor before going on to the next
step.
The following web page will help you design your algorithm and
pseudocode:
http://www.coquitlamcollege.com/adawson/Pseudocode.htm
You may include your algorithm in comments in your code or supply a separate
text file.
Step 3
Development the pseudocode from your algorithm.
The following web page will help you design your algorithm and
pseudocode:
http://www.coquitlamcollege.com/adawson/Pseudocode.htm
You may include your pseudocode in comments in your code or supply a separate
text file.
Step 4
Using your pseudocode as a guide, implement your program in the
VB language.
Your program should start with a comment block that contains the
following information:
' File: HW2.frm (HW2.vbp)
' Purpose:
Calculations using the Pythagorean theorem
' Programmer: [write your name here]
' Course: CSCI110A
' Date: [write the date name here]
' Algorithm:
' Pseudocode:
' Test data:
Please note: any statements in a VB program that start with the
' symbol are known as comments. Comments are ignored when the program runs, but
are useful when we read a program, because they supply information about
the program. They are always used
at the top of a program to supply information about the purpose of a program,
its file name, the programmer etc, as shown above. They are also used in the
body of a program to explain parts of the program which may be hard to
understand. Example programs in this course will demonstrate the correct use of
comments. You are expected to supply the above set of comments (updated
appropriately) for all of your lab and homework programming assignments.
Step 5
Test your program by running supplying
your own test data. You should test your program with at least 3 sets of test
data. Show your test data and results in comments at the top of your program.
Step 6
On the due date, you should save your homework
files (HW2.vbp and HW2.frm) and any algorithm and pseudocode files to your
folder on the network in:
CSCI110A\Week05\HW2
Assignment Presentations : In week 6 class 1, a random selection of lab assignment programs will
be presented to the CSCI110A group.
Program
points will be based on the following marking scheme:
Marking
Scheme
Student
Name:
Lab
code:
CSCI110A - Homework 2 - Fall 2004
|
Category |
Points |
Description |
|
Algorithm |
10 |
An informal description of the
steps that must be taken to solve the problem. |
|
Pseudocode |
10 |
A formal description of the
steps that must be taken to solve the problem. |
|
Comments |
10 |
The program should be commented as specified
in this document. |
|
Style |
10 |
The source code should use meaningful variable
names (identifiers) and is indented (spaced out) correctly. |
|
Design |
10 |
Appropriate data types are used. |
|
Modularity |
10 |
The program has
appropriate modularity |
|
GUI Output |
10 |
Screen prompts and outputs (user interface)
should be user-friendly. |
|
Correctness |
10 |
The program compiles with 0 errors and outputs
correct results. |
|
Completeness |
10 |
The program should be complete. |
|
Test |
10 |
Comments in the code explain how the code was
tested. |