# CMSC 104, Section 01, Fall 2016 Problem Solving and Computer Programming

## Project 2

Due Date: Thursday, October 6th @ 5:30 PM

Point Value: This project is graded with a 25 point max score.

Objectives:

To become more familiar 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:
1. solve the problem as stated, and
2. give a generic algorithm for solving the problem.

The answers to problems 1-3 should be typed into a file named campusid_proj2.txt in pseudocode. Use a similar format to the one in the Algorithms II lecture. You DO NOT need to write C code for problems 1-3.

1. (5 points) Determine the dollar 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.

2. (5 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.

3. (5 points) Bob loans Bill \$0.01 (one penny) under the condition that for every day that Bill does not pay Bob back, the amount that Bill owes Bob doubles (x2). If Bill does not pay Bob back, how many days go by before Bill owes Bob 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.

Hints for problems 1-3:
• You don't need complex algebra to solve any of these problems!
• Review the Algorithms II slides, particularly slides 20-25.
• Try to think like a computer!

4. (10 points) Write a C program, called campusid_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.

Hints:
• You only need a total of one scanf and two printf calls!
• You can print/scan the value of more than one variable in a single printf/scanf call.
• Check the third slide of the Algorithms II lecture for more help with scanf and printf. The textbook is also helpful.
• DO NOT cut and paste from Microsoft Word or other text editors into your terminal window! They use non-standard characters that confuse gcc. I will explain more in class.

Compile campusid_hello.c with the "gcc" compiler. Execute your program to verify that it works correctly.

When you have finished, submit your campusid_proj2.txt and campusid_hello.c files using the following two commands:

curl -L -F file=@campusid_proj2.txt http://userpages.umbc.edu/~reicht1/classes/cmsc104/fall16/submit.php

curl -L -F file=@campusid_hello.c http://userpages.umbc.edu/~reicht1/classes/cmsc104/fall16/submit.php

Additionally, email your campusid_proj2.txt and campusid_hello.c files as an attachment to reicht1@umbc.edu using the subject line Project Submission - 2 - Lastname, Firstname, replacing Lastname, Firstname with your name.

Last Modified: October 5th, 2016 12:25 AM