CMSC 15200 - Summer 2013

Homework #1 (Short): Due: Friday August 2nd, 2013 @ 8pm

This homework will give you practice with variables, expressions, and selection statements.

Problem #1: Taxable Income (income.c)

In one state, single residents are subject to the following income tax:

Income Tax Amount
Not over $650 2% of income
$650 - $2,375 $45.36 plus 3% of the amount over $650
$2,375 - $3,239 $75.71 plus 4% of the amount over $2,375
$3,239 - $6,039 $123.12 plus 5% of the amount over $3,239
$6,039 - $8,412 $178.93 plus 6% of the amount over $6,039
Over $8,412 $302.36 plus 7% of the amount over $8,412

Write a program that asks the user to enter the amount of taxable income, then displays the tax due. Include the dollar sign in the tax due output and format the tax to two decimal places (e.g. Tax Due: $34.24). The values on right are inclusive. This program is required to be written in a file called income.c


Problem #2: How to pay (pay.c)

Write a program that finds the minimum number of bills ($100,$50,$20,$5,$10,$1) and coins ($.25, $.10, $.05, $.01) necessary to return a given amount of money (Note: we do not consider silver dollars, 50c coins, or bills bigger than $100)
Enter amount:3673.64

$100 bills: 36

$50 bills: 1

$20 bills: 1

$10 bills: 0

$5 bills: 0

$1 bills: 3



$.25 cents: 2

$.10 cents: 1

$.05 cents: 0

$.01 cents: 4                    
                  
This program is required to be written in a file called pay.c

Hint #1: You should use integer values throughout, and not floating-points for calculating the various bill/coins amounts.

Problem #3: Calendar Dates (dates.c)

Write a program that asks the user to enter two dates and then indicates which date comes earlier on the calendar:

Enter first date (mm/dd/yy):03/06/08
Enter second date (mm/dd/yy):05/17/07

05/17/07 is earlier than 03/06/08                 
                  
The prompts and output should look excatly like the example above but of course with the dates being interchangeable. If the dates are same state that they are the same. This program is required to be written in a file called dates.c


Style and Conventions

At the top of your C files, write a comment with your name, etc., in the following form:

                /* Jane Doe, jdoe */
                /* CS152, Summer 2013 */
                /* HW#1: Problem #(1 or 2, or 3) */
                
This information is not strictly necessary, since your files are already identified by their names and the repository they reside in. Nevertheless, the redundancy is a helpful convenience for us when we are browsing and/or grading your work.

Comments, where they occur, should be helpful and precise. Do not comment the obvious:

                int a = b + c; /* I'm adding b and c! */
                
is poor style.

Your code should be no more than 80 columns wide.

Do not write more than one statement on a line.


Submitting Your Work

Save and commit your code (income.c, pay.c, dates.c) in YOUR-REPOSITORY/hw1. Recall that you will need to add your work before you commit it. (Also, notice that in the -m message you include at commit time, -m is simply a command-line option.)

Commit your work early and often. We do not grade intermediate commits, only the work as it stands at the deadline. If you have any issues with subversion, not only your instructors but your classmates can help you. Most of the students in this class have at least one full quarter of experience running subversion.

If, for any reason, perhaps due to a late add, you do not have a CS repository, save your work somewhere you can easily get it and send mail to Adam. We'll get you set up with a repository in time to make the deadline.