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
X on this web page
The program must then report the tax, as an integer.
Have a look at the sample script
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
to test all the programs I will want to use redirection from prepared
input. This requires that you and I have a precise agreement on the
TESTING AND CORRECTNESS:
Your program must conform to the rules below. We will discuss and
the meaning of these rules in class.
- 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.
- 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?)
- Testing should verify that each branch of a choice statement (for
example if-else) works correctly.
You should use int variables in this program for the income and the
Since the program will report dollars but not cents, it is permissable
reported value of the tax is incorrect by up to one dollar more or less
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
Nevertheless the code above is OK. It just computes the real number
corresponding to the expression, and then the decimal part is "thrown
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)
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
- 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,
For the due dates, see the class schedule
For more advanced
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 script should check that each
case of the switch is entered and
for at least one case check that each branch of the if is entered.
assignment created by Dr. Sarraille.