Anne
Dawson: CSCI102A_HW1_SP04.htm
First
created: Saturday 17th January 2004, 12:05 PT, AHD
Last updated: Friday 21st
January 2004, 7:09 PT, AHD
This
document is subject to change without notice.
Please
report any errors or omissions in this document:
adawson@coquitlamcollege.com
For due
date, see course schedule.
Special
instructions: Each student must
complete this homework.
CSCI102A
Homework 1
-------------------
Specification:
-------------
The
objective of this homework is to write a program which
calculates
the value of p from the infinite series
p = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + . . .
Print a table showing the value of p
approximated by one term of the series, by two terms, by three terms, etc.
The first term is 4, so after including just
one term, pi approximates 4
With the second term, pi approximates (4 -
4/3), so you must calculate the result of the expression (4 - 4/3), which is 4 -
1.3333333 or 2.666666, so your table now looks like:
pi
4
2.666666
The next number in the table is calculated
from the first three terms:
4 - 4/3 + 4/5 which is 3.466667
so the table now looks like:
pi
4
2.666666
3.466667
Notice how the number is getting closer to
3.142 which is the value of pi to 3 decimal places.
Continue calculating in the same fashion
but stop after the expression has 4/21 as the last term. This means that in
total, there will be eleven (11) numbers in the table.
Marking
Scheme :
--------------
The following
marking scheme applies:
Course
Code: CSCI102A
Semester: SP04
Assignment
Code: HW1
Lab
Specification: Approximating p
Instructor
Name: Dr Anne Dawson
Student
Name:
Student
Number:
DESIGN
1. Appropriate data types are used. /10
2. Appropriate control structures are used
(i.e. loops and decisions). /10
3. The User Interface (output to the screen) is
clear and tidy. /10
MAINTAINABILITY
4. The program is commented appropriately -
including
programmer name, date and filename. /10
5. The program has meaningful identifiers. /10
6. The program is indented (spaced out) correctly,
to
aid the understanding of the code. /10
7. The code is easy to follow. /10
CORRECTNESS:
8. The program compiles with 0 errors and 0
warnings. /10
9. Appropriate test data and results
are shown in the comments at the top of
the code.
An appropriate number and variety of test
data
sets is supplied. /10
10. The
program is complete. /10
Total: /100
Date: