Starting from:
$29

$26.10

Assignment 1 Calculate Gross Income and Taxes for a Salesperson

Assignment 1 Calculate Gross Income and Taxes for a Salesperson

Problem statement
Calculating gross income and taxes is common practice. Suppose you are tasked to write a C++
program that calculates and displays the gross income, taxes that must be paid by a car salesperson, if
any, and the remaining income. To keep it simple, let’s assume the car salesperson is only responsible
for selling one specific car model. The program should prompt the user for the following:
• monthly salary
• number of months worked in a year
• cost of a car
• number of cars sold
• number of misconducts observed
• in which tax year
• in which state
Step I – Calculate Gross Income
The gross income is calculated as follows:
Gross income = Annual salary + 2% of the profit – Deduction
Where:
- Annual salary = monthly salary * number of months worked in a year
- Profit = number of cars sold * (average selling price of a car (randomly generate a number that
is 5% - 10% above the cost) – cost of a car) (Hint: use rand() function)
- Deduction =
o $0 if number of misconducts observed is 0
o 100 * (2
𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑚𝑖𝑠𝑐𝑜𝑛𝑑𝑢𝑐𝑡𝑠 𝑜𝑏𝑠𝑒𝑟𝑣𝑒𝑑−1
) otherwise (Hint: use pow() function)
▪ The amount of deduction gets doubled as the number of misconducts observed
increases. For example, 1 misconduct == $100, 2 misconducts == $200, 3
misconducts == $400, and so on.
For example, suppose the monthly salary of my salesperson is $5,000, working 10 months in a year. In
the past year, the cost of a car is $36,000, and 30 cars sold. The salesperson has been observed 4
misconducts. The average selling price of a car, generated randomly, is $38,000.
Then, the gross income = 5000 * 10 + 2% * ((38000 – 36000) * 30) – 100 * 𝟐
𝟒−𝟏
 = 50400.
Step II – Calculate Taxes
Taxes of the car salesperson is calculated based on the following rules:
- Tax Year 2017:
• State A:
o You’ll pay 6% of your income
• State B:
o For income below $2000, you’ll pay $0
o For income between $2000 and $10,000, you’ll pay $100
o For income over $10,000, you’ll pay 10%, plus $100
• State C:
o For income between $0 and $3,500, you’ll pay 5%
o For income between $3,500 and $9,000, you’ll pay 7%, plus $175
o For income between $9,000 and $125,000, you’ll pay 9%, plus $560
o For income over $125,000, you’ll pay 9.9%, plus $11,000
- Tax Year 2018:
• State A:
o You’ll pay 8% of your income
• State B:
o For income below $2500, you’ll pay $0
o For income between $2500 and $10,000, you’ll pay $115
o For income over $10,000, you’ll pay 10.5%, plus $115
• State C:
o For income between $0 and $3,450, you’ll pay 5%
o For income between $3,450 and $8,700, you’ll pay 7%, plus $172.5
o For income between $8,700 and $125,000, you’ll pay 9%, plus $540
o For income over $125,000, you’ll pay 9.9%, plus $11,007
For example, suppose it is tax year 2017 and the car salesperson is from State C, the gross income is
$50,400, then the tax he/she needs to pay is (50400 – 9000) * 9% + 560 = 4286.
Example run:
Enter your monthly salary: 5000
Enter number of months you worked in the past year: 10
Enter the cost of the car: 36000
Enter number of cars you’ve sold in the past year: 30
Enter number of misconducts observed in the past year: 4
Which tax year are you in, enter 1 for 2017, 2 for 2018: 1
Which state are you in, enter A, B, or C: C
The average selling price, generated randomly, is $38000, you will earn 2% of the profit, which is
$1200.
The gross income is: $50400
The tax you need to pay is: $4286
Remaining: $46114
Note:
There’s no error handling needed in program code part, meaning that you can assume all inputs are
good. However, you do need to think about this in design level. For example, what if the user entered 13
for number of months worked in a year? What if the user entered 3.6 for number of cars sold?
Design Document – Due Sunday 1/10/2021, 11:59pm on Canvas
Refer to the Example Design Document – Example_Design_Doc.pdf
Guiding questions:
Understanding the Problem/Problem Analysis:
• What are the user inputs, program outputs, etc.?
• What assumptions are you making?
• What are all the tasks and subtasks in this problem?
Program Design:
• What does the overall big picture of this program look like? (Flowchart or pseudocode)
o What data do you need to create, when you read input from the user?
o How to name your variables?
o What are the decisions that need to be made in this program?
Based on your answers above, list the specific steps or provide a flowchart of what is needed
to create. Be very explicit!!!
Program Testing:
Create a test plan with the test cases (bad, good, and edge cases). What do you hope to be the
expected results?
• What are the good, bad, and edge cases for ALL input in the program? Make sure to
provide enough of each and for all different inputs you get from the user.
Electronically submit your Design Doc (.pdf file!!!) by the design due date, on Canvas.
Program Code – Due Sunday, 1/17/2021, 11:59pm on TEACH
Implementation Requirements:
• Must produce a working program that follows each rule stated above
• You must use rand() function when calculating profit
• You must use pow() function when calculating deduction
• Your user interface must provide clear instructions for the user and information about the data
being presented
• No global variables allowed (those declared outside of many or any other function, global
constants are allowed).
Program Style/Comments Requirements:
In your implementation, make sure that you include a program header in your program, in addition to
proper indentation/spacing and other comments! Below is an example header to include. Make sure
you review the style guidelines for this class, and begin trying to follow them, i.e. don’t align everything
on the left or put everything on one line!
/*******************************************************************
** Program: assignment1.cpp
** Author: Your Name
** Date: 01/01/2020
** Description:
** Input:
** Output:
*******************************************************************/
Electronically submit your C++ program (.cpp file, not your executable!!!) by the code due date,
on TEACH.
Remember to sign up with a TA on Canvas to demo your assignment. The deadline to demo
this assignment is 1/29/2021.
***If you are doing this off campus, pay attention to the off-campus directions from lab! 

More products