CS 1500-1, Spring 2010
Solo Program 2

Your assignment is to write a program that estimates 2009 federal income tax for single filing status.

INPUT AND OUTPUT:

The program must prompt for the taxable income. The user will input a non-negative integer taxable income.

The program must compute the estimated tax on the taxable income, using Schedule X on this web page.

The program must then report the tax, as an integer.

Have a look at the sample script to see how it should look when you run the program. Make sure to write the program so that it inputs only the taxable income. If I decide I want to test all the programs I will want to use redirection from prepared files of input. This requires that you and I have a precise agreement on the form of the input.

TESTING AND CORRECTNESS:

Your program must conform to the rules below. We will discuss and clarify the meaning of these rules in class.
1. The test script must show testing of a representative sample of ordinary data. It must also show coverage on and near at least two boundary data values.
2. If I run your program and it gives an incorrect result, then you may lose a very substantial amount of the credit for this assignment. (How tolerant would you be of a tax program that gives wrong answers?)

DESIGN DETAILS:

You should use int variables in this program for the income and the tax.

Since the program will report dollars but not cents, it is permissable if the reported value of the tax is incorrect by up to one dollar more or less than the true amount.

When you compile code like this
`int tax ;if (income <= 31850) tax = 782.50 + 0.150 * (income - 7825) ;`
you may see a warning from the compiler like this:
`warning: converting to 'int' from 'double' `
because the code assigns a real number (double) to the integer variable tax.

Nevertheless the code above is OK. It just computes the real number corresponding to the expression, and then the decimal part is "thrown away" when the value is assigned to the variable. The value that tax gets is incorrect by no more than \$0.99.

A compiler warning is not the same thing as a syntax error. It does not prevent the compiler from producing an executable version (translation) of your program.

WHAT TO TURN IN:

Here is the list of things you have to turn in:
• At the start of class on the due date place the following item on the "counter" in front of me:

• a hardcopy (printed listing) of your program (the C++ source code). Make sure all the code is properly formatted and that it all shows on the paper.

• Before midnight on the the due date upload the following to the Homework Submission System:

• A copy of the source code (C++ code) (be sure your name is in the comment section at the beginning of the program), named sprog2.cpp

• and a (filtered) script showing a test run of the program, named solo2.script

DUE DATES:

For the due dates, see the class schedule.

EXTRA CREDIT:

For extra credit you can implement all four tax tables, using a switch statement. Prompt the user for their filing status (provide a menu to tell them what to enter, e.g. "enter S for Single") and use the value they enter as the controlling expression for the switch.

Your scipt should check that each case of the switch is entered and within each case each branch of the if is entered.

Based on an assignment created by Dr. Sarraille.