Professional Documents
Culture Documents
CSCI 40 / ENGR 40 - Term Project Assignment - Part I 2014 Fall
CSCI 40 / ENGR 40 - Term Project Assignment - Part I 2014 Fall
CSCI 40 / ENGR 40 - Term Project Assignment - Part I 2014 Fall
2014 Fall
All programs:
Use functions when it is appropriate
Document your code
Use indentation to make your program readable
Give all possible test cases.
Grading Scale:
50 points Program compiles and executes
10 points Use 5 functions or more
5 points Documentation and comments
5 points Indentation and readability
30 points properly designed test cases.
1 of 5
(b) Write a program that estimates the value of ex, using the formula:
ex =1 +
x x 2 x3 x 4
+
+
+
+L
1! 2! 3! 4!
Have the user enter the "x" value, and your program displays ex; until
user decided to stop. Do not use pow() function
Check your result using a calculator
Display the ex value using 3 terms, 4 termsetc.
Your test cases should demonstrate that more terms are used, closer
the e-value to 2.71828182846
2. (3 points) Calendar
Write a program to generate a calendar for any year. The program should
accept (a) the year and (b) the day of the week for January 1 of that year.
Following is an example for using input:
What year is this? 2013
1
2
3
4
5
6
7
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
This program will create a one-page calendar, write the result to a file.
2 of 5
Remember, February has 29 days if the year is a leap year. The calendar should
be printed in the following form (for each month)
Next page is the output for 2014.
Use "Courier" font to lineup the output.
January 2014
S M T W
-- -- -- -1
5 6 7 8
12 13 14 15
19 20 21 22
26 27 28 29
T
-2
9
16
23
30
F
-3
10
17
24
31
February 2014
S
-4
11
18
25
April 2014
S M T
-- -- -1
6 7 8
13 14 15
20 21 22
27 28 29
W
-2
9
16
23
30
T
-3
10
17
24
F
-4
11
18
25
S
-5
12
19
26
July 2014
S M T
-- -- -1
6 7 8
13 14 15
20 21 22
27 28 29
W
-2
9
16
23
30
T
-3
10
17
24
31
F
-4
11
18
25
T
-2
9
16
23
30
F
-3
10
17
24
31
S M T W T F S
-- -- -- -- -- -- -1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
S M T W T F S
-- -- -- -- -- -- -1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
May 2014
June 2014
S M T W T
-- -- -- -- -1
4 5 6 7 8
11 12 13 14 15
18 19 20 21 22
25 26 27 28 29
F
-2
9
16
23
30
S
-3
10
17
24
31
S
-1
8
15
22
29
M
-2
9
16
23
30
August 2014
S
-5
12
19
26
October 2014
S M T W
-- -- -- -1
5 6 7 8
12 13 14 15
19 20 21 22
26 27 28 29
March 2014
S M T W T F
-- -- -- -- -- -1
3 4 5 6 7 8
10 11 12 13 14 15
17 18 19 20 21 22
24 25 26 27 28 29
31
S
-2
9
16
23
30
S M T W T F S
-- -- -- -- -- -- -1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
3 of 5
W
-4
11
18
25
T
-5
12
19
26
F
-6
13
20
27
S
-7
14
21
28
September 2014
November 2014
S
-4
11
18
25
T
-3
10
17
24
S M
-- -1
7 8
14 15
21 22
28 29
T
-2
9
16
23
30
W
-3
10
17
24
T
-4
11
18
25
F
-5
12
19
26
S
-6
13
20
27
December 2014
S M
-- -1
7 8
14 15
21 22
28 29
T
-2
9
16
23
30
W
-3
10
17
24
31
T
-4
11
18
25
F
-5
12
19
26
S
-6
13
20
27
3. (2 points) GPA
3 points using output file
Write a program to calculate your GPA for the semester.
(1)
User input
User will enter following information for each class
(1) name of the class
(2) unit of this class
(3) the letter grade received
until user indicates to stop.
(2)
(3)
Units
4
3
4
3
4 of 5
Grade
B
A
A
C
4. (3 points) Write functions to add, subtract, multiply and divide complex numbers.
Write a driver program uses a menu to allow user to choose the operation for
calculation.
(a + bi) + (c + di) = (a + c ) + (b + d )i
(a + bi) (c + di) = (a c) + (b d )i
(a + bi)(c + di) = (ac bd ) + (ad + bc)i
(a + bi) (ac + bd ) (bc ad )
=
+
i
(c + di) c 2 + d 2
c2 + d 2
Chapter
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Ch 3
Ch 3
Ch 4
Ch 4
Ch 5
Ch 5
Ch 5
Ch 5
Ch 5
Ch 5
Ch 6
Ch 6
Ch 6
Ch 6
Ch 6
Ch 6
Programming
Challenge
Number
17
22
17
22
2
7
8
17
23
16 & 26
5
6
7
8
9
21 &22
Page
Number
Point
146
148
223
225
294
295
295
297
298
296 & 299
370
370
370
371
371
375
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
5 of 5
Comment
Monthly Payment
Word Game
Spectral Analysis
Long Distance Call
ASCII
Pennies
Math
Bar Chart
Pattern
Balance (Account)
D
KE
Celsius Temperature Table
Coin Toss
Present Value
Prime