Waiting to be taken up by the state legislature is a proposal for a major reform of the state income tax code. Your job is to write a program that determines how much a taxpayer would pay under the...

1 answer below »

Waiting to be taken up by the state legislature is a proposal for a major reform of the state income tax code. Your job is to write a program that determines how much a taxpayer would pay under the plan.


Your program must accept as input the taxpayer's name, taxable income, occupation, and number of children. The output will tell how much tax that the taxpayer would pay under the plan.


Here is an example of a dialog with the program (user input is shown inboldface):



Name:
Samuel Henryi
Taxable income:
110000
Occupation:
engineer
Number of children:
6
--- Samuel Henryi would pay $3800.00

According to the plan:



  • The first $50000 of taxable income is taxed at 4%.

  • The next $70000 of taxable income is taxed at 6% in general. However, if the taxpayer's occupation isengineerorscientist(so spelled, entirely in lower case), the income in this bracket is taxed at only 5%.

  • The amount of taxable income that exceeds $120000 is taxed at 9%.

  • If the taxable income is under $120000, the tax is reduced by $200 per child; however, the tax is never allowed to go below zero.


As an example, Samuel above would incur $2000 of tax liability for the first $50000 of his income, plus $3000 for the next $60000 of income in the second bracket, for a total of $5000. That tax is reduced by $200 per child, so he would pay $3800.


Here's another example:



Name:
Moe Szyslak
Taxable income:
29544.69
Occupation:
bartender
Number of children:
0
--- Moe Szyslak would pay $1181.79

You can test your understanding of the tax schedule by experimenting with thetax proposal calculatorwe found at the legislature's website.


Your program must collect the information for one taxpayer in the manner indicated by the examples, and then write tocouta line with three hyphens only (no spaces or other characters), followed by exactly one line in a format required below. Our grading tool will judge the correctness of your program by examining only the line following the line with three hyphens (and verifying that there are no additional lines). That one line you write must be in one of the following five forms; the text must beidenticalto what is shown, except thatitalicizeditems are replaced as appropriate:



  • If an empty string was provided for the name:

    You must enter a name

  • If the taxable income is negative:

    The taxable income must be nonnegative

  • If an empty string was provided for the occupation:

    You must enter an occupation

  • If the number of children is negative:

    The number of children must be nonnegative

  • If the input is valid and none of the preceding situations holds:


    namewould pay $amount



In the last case,namemust be the name the user entered, andamountmust be the correct answer, shown as a non-negative number with exactly two digits to the right of the decimal point. 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 messagesexactly. Here are some foolish mistakes that may cause you to get very few points for correctness on this project, no matter how much time you put into it, because the mistake will cause your program to fail most or all of the test cases we run:



  • Not writing tocouta line with exactly three hyphens inallcases.

  • Writing any spaces on the line that is supposed to have three hyphens.

  • Writing more than one line after the line with three hyphens. Don't, for example, add a gratuitous "Tax plan details subject to change."

  • Writing lines tocerrinstead ofcout.

  • Writing lines like these:

    Montgomery Burns woud pay $12345678.90
    misspelling
    Montgomery Burns Would pay $12345678.90
    wrong capitalization
    Montgomery Burns pays $12345678.90
    wrong text
    Montgomery Burns would pay $ 12345678.90
    extra space
    Montgomery Burns would pay $12345678.90.
    extra period
    Montgomery Burns would pay $12345678.900
    extra digit
    Montgomery Burns would pay 12345678.90
    missing dollar sign
    Emmett Brown would pay $98765
    missing decimal point and digits



Your program must gather the name, the taxable income, the occupation, and the number of children in that 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 tocoutthe line of three hyphens, the required message, and nothing more after that. If instead you choose to gather all input first before checking for errors, and you detect more than one error, then after writing the line of three hyphens, write only the error message for the earliest erroneous item.


You will not write any loops in this program. This means that each time you run the program, it handles only one taxpayer. 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.


A string with no characters in it is the empty string. A string with at least one character in it is not the empty string, even if the only characters in it are things like spaces or tabs. Although realistically it would be silly to have a taxpayer name consisting of seventeen spaces and nothing more, treat that as you would any other non-empty string: as a valid name. (Since you don't yet know how to check for that kind of situation anyway, we're not requiring you to.)


The one kind of input error that your program doesnothave to deal with, because you don't yet know how to do so, is not finding a number in the input where a number is expected. We promise that our grading tool will not, for example, supply the textnot enoughwhen your program requests the income or the number of children. We also promise that our grading tool will supply an integer for the number of children, not a number like2.5.


The correctness of your program must not depend on undefined program behavior. Your program could not, for example, assume anything aboutn'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 two files and nothing more:



  1. A text file namedtax.cppthat 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.

  2. A file namedreport.docxorreport.doc(in Microsoft Word format) orreport.txt(an ordinary text file) that contains:

    1. 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++.)

    2. 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:


      More people surveyed than the total obeying and disobeying (1000, 413, 382)


      Fewer people surveyed than the total obeying and disobeying (500, 413, 382)


      Zero people surveyed (0, 100, 100)


      Data giving a non-integer percentage (1000, 413, 382)


      More people obeying than disobeying (1000, 413, 382)


      Equal number of people obeying and disobeying (1000, 500, 500)








By April 15, there will be links on the class webpage that will enable youto 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 and report 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 writeupSome Things about Stringstells you what you need to know about strings for this project.


As you develop your program, periodically try it out under another compiler (g31 on cs31.seas.ucla.edu if you're doing your primary development using Visual C++ or Xcode). 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.

Answered Same DayApr 17, 2021

Answer To: Waiting to be taken up by the state legislature is a proposal for a major reform of the state income...

J Anitha answered on Apr 17 2021
156 Votes
Test Data
1)
Name: Samuel Henryi
Taxable Income: 110000
Occupation:(engineer/scientist/doctor/te
acher/business/others) You must enter a Occupation
engineer
Number of Children: 6
Samuel Henryi would pay $3800
Process exited after 31.09 seconds with return value 0
Press any key to continue ....
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here