Starting from:

$30

CS31- Project 2: Stimulus Check Calculator Solved

In response to the emergence of the novel coronavirus in the United States, Congress passed the CARES Act (the Coronavirus Aid, Relief and Economic Security Act) which was signed into law on March 27, 2020.  Among its many provisions, the $2 trillion stimulus bill arranged for direct payments to many US taxpayers.  The plan created a tax rebate of $1,200 per taxpayer plus $500 per dependent child.  The amount of the rebate is gradually reduced for incomes above $75,000 per year for individuals, $112,500 for heads of households, and $150,000 for married filers. These rebates gradually phase out as income rises, dropping to zero above $99,000 per year for single filers with no children, $112,500 136,500 for head of household filers with no children and $198,000 for married filers with no children, as the following graphic shows:

 

The payment amount falls by $5 for every $100 in income above the full payment level which is $75,000 for individual filers, $150,000 for married couple filers and $112,500 for head of household filers.

Here is an example of a dialog for the program I am asking you to create (user input is in boldface):

What is your filing status? Single
What is your adjusted gross income? 50000
How many children under the age of 17 did you claim as a dependent? 0
Your stimulus check is $1200.
 

The following table shows the costs your program should work with:

Stimulus Check Parameters
Filing Status
  Single
        Married    
 Head of Household
Full Stimulus Payment
$1,200
$2,400
$1,200
Each Dependent Under 17 Increases Payment By:
additional $500
 Full Payment Up To Incomes Of:
$75,000
$150,000
$112,500
 Payment Reduction
$5 reduction for each $100 in income above the Full Payment Limit
 

Here's a few other examples to give you a sense of how it should work:       

 
What is your filing status? Head of Household
What is your adjusted gross income? 200000
How many children under the age of 17 did you claim as a dependent? 0
Your stimulus check is $0.
 

What is your filing status? Color Television
What is your adjusted gross income? 0
How many children under the age of 17 did you claim as a dependent? 0
Error - Invalid filing status.
 

What is your filing status? Married
What is your adjusted gross income? 200000
How many children under the age of 17 did you claim as a dependent? 1
Your stimulus check is $400.
You can test your understanding of the cost requirements by experimenting with the calculator we found at this website .

 

Your program must collect the information for one taxpayer in the manner indicated by the examples, and then write to cout exactly one line in a format required below. Our grading tool will judge the correctness of your program by examining your output . That line you write must be in one of the following seven four forms; the text must be identical to what is shown (except that the italicized cccc should be the appropriate numeric value calculated by your program:

If the user enters a filing status value which is not "Single", "Married" or "Head of Household":
   Error - Invalid filing status.
If the user enters an income less than zero:
       Error - Invalid income.
If the user enters a number of children less than zero:   
   Error - Invalid number of dependents.
Otherwise: 
   Your stimulus check is $cccc.
The lines you write must not start with any spaces. If you are not a good speller or typist, or if English is not your first language, be especially careful about duplicating the messages exactly . Here are some foolish mistakes that may cause you to get no points for correctness on this project, no matter how much time you put into it:

Writing any extra spaces on the output line.
Writing more than one line of output. Don't, for example, add a gratuitous "Thank you for using my great stimulus calculator!"
Writing lines to cerr instead of cout .
Writing lines like these:
Your stimulus check is $1200                missing period
Yyour stilmus check is $1200.               misspelling
YOUR STIMULUS CHECK IS $1200.               wrong capitalization
Your stimulus check is $1200  .             extra spaces
Your stimulus check is $1,200.00            incorrect number format
Your program must gather the filing status, the income level and the number of dependents, in that specific order. However, if you detect an error in an item, you do not have to request or get the remaining items if you don't want to; just be sure you write to cout the required error message and nothing more after that. If instead you choose to gather all input first before checking for any errors, and you detect more than one error, then write only the error message for the first erroneous input item.

You will not write any loops in this program. This means that each time you run the program, it handles only one check calculation. It also means that in the case of bad input, you must not keep prompting the user until you get something acceptable; our grading tool will not recognize that you're doing that.

Additionally, I have created a testing tool called CodeBoard to help you check your code.  CodeBoard enables you to be sure you are naming things correctly by running a small number of tests against your code.  Passing CodeBoard tests is not sufficient testing so please do additional testing yourself.  To access CodeBoard for Project 2, please click the link you see in this week named CodeBoard for Project 2.  Inside the file named user_functions.cpp, copy and paste the body of your main( ) function inside the function named student_main( ) .  CodeBoard uses its own main( ) to run tests against your code.  Click Compile and Run.  However please be aware that no editing changes can be saved inside CodeBoard.  In this anonymous user configuration, CodeBoard is read-only and does not allow for saving changes.

The correctness of your program must not depend on undefined program behavior. Your program could not, for example, assume anything about n 's value at the point indicated:

int main()
{
int n;
int m = 42 * n;  // n's value is undefined


What you will turn in for this assignment is a zip file containing these three files and nothing more:

A text file named stimulus.cpp that contains the source code for your C++ program. Your source code should have helpful comments that tell the purpose of the major program segments and explain any tricky code.
A file named report.doc or report.docx (in Microsoft Word format) or report.txt (an ordinary text file) that contains in addition your name and your UCLA Id Number:A brief description of notable obstacles you overcame. (In Project 1, for example, some people had the problem of figuring out how to work with more than one version of a program in Visual C++.)
A list of the test data that could be used to thoroughly test your program, along with the reason for each test. You don't have to include the results of the tests, but you must note which test cases your program does not handle correctly. (This could happen if you didn't have time to write a complete solution, or if you ran out of time while still debugging a supposedly complete solution.) For Project 1, for example, such a list, had it been required, might have started off like this:

Negative number of tests (-1000, 1, 2, 3, 4)

Negative number of positives (1, -413, 2, 3, 4)
Negative number of false positives (1, 2, -10, 3, 4)

All zeros  (0, 0, 0, 0, 0)

Equal numbers (200, 200, 200, 200, 200)


A file named hw.doc or hw.docx (in Microsoft Word format) or hw.txt (an ordinary text file) that contains your solution to the homework accompanying Project 2.
By July 6, there will be a link on the class webpage that will enable you to turn in your zip file electronically. Turn in the file by the due time above. Give yourself enough time to be sure you can turn something in, because we will not accept excuses like "My network connection at home was down, and I didn't have a way to copy my files and bring them to a SEASnet machine." There's a lot to be said for turning in a preliminary version of your program, report, and homework early (You can always overwrite it with a later submission). That way you have something submitted in case there's a problem later. Notice that most of the test data portion of your report can be written from the requirements in this specification, before you even start designing your program.

The writeup Some Things about Strings tells you what you need to know about strings for this project.

As you develop your program, periodically try it out under another compiler (g++ if you're doing your primary development using Visual C++, or Visual C++ if you're doing your primary development using clang++ or g++ (e.g., with Xcode on a Mac)). Sometimes one compiler will warn you about something that another is silent about, so you may be able to find and fix more errors sooner. If running your program under both environments with the same input gives you different results, your program is probably relying on undefined behavior (such as using the value of an uninitialized variable), which we prohibit.

G31 Build Commands
g31 -c stimulus.cpp
g31 -o runnable stimulus.o
./runnable

More products