For 2011 and 2012, there were two tax credits available to help offset the costs of higher education by reducing the amount paid in income tax. They are the American Opportunity Credit and the Lifetime Learning Credit. A taxpayer may choose to claim only one of these two credits for each student in a single tax year. Married taxpayers, filing separately, may not claim either of these credits.
You will write a program that carries out the logic for the Lifetime Learning Credit (modified from IRS form 8863). A taxpayer may be allowed up to 20% of the first $10,000 of qualified educational expenses (i.e. $2,000) as a tax credit, depending upon his/her income. Sample input and output that can be used as a test case is also given below.
Possible Required Input:
- Filing status (one of the following)
- Married, Filing Jointly,
- Head of Household,
- Qualifying Widow,
- Married, Filing Separately.
- Amount of Qualified Educational Expenses
- Adjusted Gross Income (1040 line 38)
Sample Input 1a
Lifetime Learning Credits Worksheet Creation Program
1 - Single
2 - Married, Filing Jointly
3 - Head of Household
4 - Qualifying Widow(er)
5 - Married, Filing Separately
Enter your filing status from above (1-5): 2
If the user enters 1-4 (but not 5), you will also need to read the other input:
Sample Input 1b
Enter the Amount of Qualified Educational Expenses for 2011: 8350
Enter your Adjusted Gross Income (from 1040 line 38): 105000
NOTE: No error checking of the user input is required. You may assume that the user entered a valid answer for each question.
In your previous programs, you have seen the line:
used to return from the main function.
When we finish running the code in the main function, the program is done executing. So when you return from within main, it finishes the execution of main, and ends the program. (Note that returning from any function other than main does not end the program.)
So the return line causes the program to end execution, and returns an "exit code" of 0 (zero) to the operating system. On most operating systems, an exit code of zero indicates that the program ran successfully.
A program can also return from main using any other integer value as the exit code, to indicate that the program exited for some specific reason.
For example, this line in main:
will cause the program to exit and pass back exit code 5 to the operating system. It is up to the programmer to decide what each exit code means. See WBW section 3.8 for more details.
You will use a couple of different exit codes in this program, depending upon what line causes an early exit, as described below.
After the initial program header has been displayed, and the program has read the filing status from the user, use the following instructions to create a Lifetime Learning Credit worksheet for the user.
IRS instructions for each line of the worksheet
Program Logic Summary
- Read the input for line 1 (filing status) from the user.
- Perform a test to determine if the taxpayer should continue, or if the exit condition for line 1 has been met.
- If the line 1 exit condition is met, there will be no credit. Display a message saying to (see Sample 3 Output below). Pause, and then return from main with exit code 1, to indicate that the line 1 exit condition was met. return 1;
- If the line 1 exit condition is not met, read the input for line 2 (qualified educational expenses) from the user.
- Perform a test to determine the amount for line 3 and store the result.
- Perform the necessary calculations for line 4 and store the result.
- Determine the line 5 income limit that applies for the filing status entered, and store the result. HINT: Also store the filing status description string here.
- Read the input for line 6 (adjusted gross income) from the user.
- Display the worksheet title and lines 1 through 6.
- Perform the line 7 test to determine if the taxpayer should continue, or if the worksheet is complete.
- If the subtraction result is 0 or less, the worksheet calculations are complete. Display 0 on line 10 (See Sample 2 Output below). Pause, and then return from main with exit code 7, to indicate that the line 7 exit condition was met. return 7;
- o If the line 7 exit condition is not met, continue.
- Perform a test to determine the amount for line 8 and store the result.
- Call the user-defined function to find the amount for line 9 and store the result returned.
- Perform necessary calculation to store the values for line 10.
- Display the remaining results for lines 7 through 10 on the worksheet, making sure that line 9 is displayed to 3 decimal places (see Sample 1 Output below).
Processing Logic Notes
- If the program exits on line 1, only a message will be displayed as output.
- If the program exits on line 7, only the worksheet title and lines 1 – 6 and 10 will be displayed, along with the message about where to enter the results.
- If neither exit condition (from line 1 or line 7) is met, then the program will display the entire worksheet and return from the main function with an exit code of 0 (to indicate the successful completion of the entire worksheet). return 0;
- For line 9, write a user-defined function that will compute the amount to enter on line 9.
- The function shall take two input arguments: the line 7 amount and the line 8 amount.
- The function will test if line 7 is equal to or more than line 8, and then compute the correct results for line 9.
- The function will return the floating point result.
- No other computations should be performed within this function. Examples: Input arguments of line 7 = 15000 and line 8 = 10000 would return 1.0 Input arguments of line 7 = 12222 and line 8 = 20000 would return 0.6111
Display a Lifetime Learning Credit Worksheet that adheres to the formatting constraints shown below (decimals in dollar values should line up as shown).
Sample 1 Output (no early exit – using sample inputs 1a and 1b from above) See image.
Sample Output Notes
- Make sure there are a couple of blank lines AFTER all input has been entered and BEFORE the worksheet is displayed.
- Lines 1 or 7 may cause the program to display some results and immediately exit, without displaying the rest of the worksheet (see samples 2 and 3 below)
Sample 2 Input See image.
Sample 2 Output (early exit on line 1) See image.
Sample 3 Input See image.
Sample 3 Output (early exit after line 7) See image.
- Work on one line at a time. Make sure each line is working correctly before moving on to the next line and any subsequent calculations.
- Use the example input and output to help you.
- Remember to declare constants for ALL fixed values.
- HINT: Use a separate variable to store your calculation for each line. Remember to use descriptive variable names.
- Be sure to include top of program comments that include: Your name, the course, and the assignment number What the program does including: What is Input Processing Performed What is Output
- Make sure you comment any constants/variables whose names are not completely descriptive.
- You must also include a comment above each user-defined function that includes: What the function does A description of the parameters that are input to the function A description of what is returned from the function