Project 2 - Algorithms and C Programming Basics
CMSC 104, Fall 2002
Due Date: 5:30 pm, Thursday September 26th.
Point Value:
This project is graded with a 20 point max score.
Objectives:
To become more with
- problem solving concepts
- simple algorithm development
- writing and compiling simple C programs
Problems 1-3 are problem solving and algorithm problems.
For each of these three problems, complete two
parts:
- solve the problem as stated, and
- give a generic algorithm for solving the problem.
The answers to problems 1-3 should be typed, printed on plain white paper, and turned in on 9/26.
- (3 points) Determine the value of a coin collection that contains 13
pennies, 2 nickels, 4 dimes, 7 quarters, and 5 silver dollars.
- Allow the user to input the numbers of the different coins.
- The algorithm should output the total value of the coin collection.
- (3 points) You have been saving dimes and nickels in your piggy
bank (everything counts). After counting 150 total coins, you know that you have
$9.45. How many of each coin do you have?
- Allow the user to input the total number of coins and the total dollar amount.
- The output should be the number of dimes and the number of nickels.
-
(4 points) Tom loans Tim $0.01 (one penny) under the condition that for every day that Tim does not pay Tom back,
the amount that Tim owes Tom doubles (x2). If Tim does not pat Tom back, how many days go
by before Tim owes Tom over $1,000,000.00?
- The user should be allowed to specify the initial loan
amount, the rate of increase (interest rate), and the total payback
amount to be exceeded.
- The output is the number of days that it takes the payback
amount to grow larger that the desired total payback amount.
- (10 points) Write a C program, called "hello.c", that prompts the user to input three initials, scans
the three initials, and then outputs "Hello, XYZ!", where X,Y, and Z are the three input
initials, respectively. Your program should be well formatted and documented with the necessary information
to identify it as yours in the header comment. See the C Coding Standards for more details.
Compile hello.c with the "gcc" compiler. Execute your program to verify
that it works correctly. Once you have verified you program, email the source
file, "hello.c", to the CMSC 104, 0801 TA, Pengyu Lie, pliu2@cs.umbc.edu.
Last Modified: