COP 1510 Programming Concepts I

 

Assignment 10

 

Name________________________________________

 

Section_______________________________________

 

Date__________________________________________

 

1.         Review Questions 1--55, pp. 385--388

 

2.         Modify the program you wrote for Assignment 8, part 7 (the compound interest problem) to use a function to compute the amount of the investment.  Arguments for the function should be A, R and N.

 

3.         Modify the program you wrote for Assignment 8 part 6 (Perfect/Abundant/Deficient numbers) to include two functions:  one to compute the sum of the divisors of a number and a second to perform the output based on the relationship between the number and the sum of its divisors.

 

4.         Exercise 4 p. 390 (Average number of days a company’s employees are absent)

 

5.         Write a program to allow the user to enter a series of numbers representing playing cards and print out the name of the card.  Card numbers in the range 1—13 represent clubs; numbers in the range 14—26 represent hearts, numbers in the range 27—39 represent diamonds, and 40—52 represent spades.  The first number in each sequence represents the two, the second represents the three and so forth; the 10th represents the Jack, the 11th represents the Queen, the 12th represents the King and the 13th represents the Ace.  Use appropriate functions to display the suite and value of each card.

 

6.         Write a program to calculate the number of combinations C of  N things taken R at a time (where N>R).  The formula is

 

                     N!          

            R! (N – R)!

 

Recall that the factorial function is symbolized by !.  The factorial of a number is computed as the product of the sequence of integers from 1 to the number.  For example,

4! = 1 x 2 x 3 x 4 = 24

6! = 1 x 2 x 3 x 4 x 5 x 6 = 720

In general n! = 1 x 2 x 3 x 4 x . . .  (n-1) x n

            

For all programming problems, follow the directions for comments and formatting found on p. 389.  Submit a printout of the program and proof of testing as described in class.

Attach this cover sheet to your work.