Sections 0101, 0102, 0103 and Honors, Fall 1995
A Step by Step Plan for Project 2
If you find Project 2 large and intimidating, you
should follow the following plan of attack and
implement the project incrementally.
The Step by Step Plan
- Write a program with a for loop that prints out:
Table of Sines
sin( 0) = ???? sin( 5) = ???? sin( 10) = ????
sin( 15) = ???? sin( 20) = ???? sin( 25) = ????
sin( 30) = ???? sin( 35) = ???? sin( 40) = ????
sin( 45) = ???? sin( 50) = ???? sin( 55) = ????
sin( 60) = ???? sin( 65) = ???? sin( 70) = ????
sin( 75) = ???? sin( 80) = ???? sin( 85) = ????
sin( 90) = ???? sin( 95) = ???? sin(100) = ????
sin(105) = ???? sin(110) = ???? sin(115) = ????
sin(120) = ???? sin(125) = ???? sin(130) = ????
sin(135) = ???? sin(140) = ???? sin(145) = ????
sin(150) = ???? sin(155) = ???? sin(160) = ????
sin(165) = ???? sin(170) = ???? sin(175) = ????
sin(180) = ???? sin(185) = ???? sin(190) = ????
sin(195) = ???? sin(200) = ???? sin(205) = ????
sin(210) = ???? sin(215) = ???? sin(220) = ????
sin(225) = ???? sin(230) = ???? sin(235) = ????
sin(240) = ???? sin(245) = ???? sin(250) = ????
sin(255) = ???? sin(260) = ???? sin(265) = ????
sin(270) = ???? sin(275) = ???? sin(280) = ????
sin(285) = ???? sin(290) = ???? sin(295) = ????
sin(300) = ???? sin(305) = ???? sin(310) = ????
sin(315) = ???? sin(320) = ???? sin(325) = ????
sin(330) = ???? sin(335) = ???? sin(340) = ????
sin(345) = ???? sin(350) = ???? sin(355) = ????
sin(360) = ????
-
Write a separate program that takes an angle in degrees from
the user and prints out the equivalent angle in radians.
-
Modify the previous program to print out the value
x - x*x*x/6 + x*x*x*x*x/120
where x is size of the angle in radians.
This is very roughly the sine of the angle, since it uses
only the first 3 terms of Taylor series.
-
Modify the program again. This time take another value
from the user, call it n.
Write a for loop that calculates the value of x raise to the n-th power.
Write a for loop that calculates (2*n - 1) factorial.
Write a boolean expression that will tell you if the n-th term
is positive or negative.
Check the answers with a calculator.
-
Put the loops and the boolean expression in the previous step
into one giant loop that iterates n from 1 to 8.
(So, you don't want to get n from the user anymore.)
Then, you can sum all the terms together and get the Taylor
series approximation.
Check your answer on a calculator.
-
Modify the previous program so that the number of terms is entered
by the user (instead of being the constant 8).
-
Put the giant for loop inside the for loop in step 1.
(Of course, now you shouldn't ask the user which angle to use.)
-
Clean up your program (indentation, comments etc.) and you are done.
Last Modified:
Tue Oct 3 14:11:05 EDT 1995
Richard Chang, chang@gl.umbc.edu