Skip Navigation
 

Assignments

Assignment 2

Barbados Community College

Division of Computer Studies

COMP 101 Algorithm and Programming Concepts Using C++

Assignment #2:  Income Tax Calculator (Part 2)

Prerequisites, Goals and Outcomes

Prerequisites: Students should have the following prerequisite skills.

  • IPO Charts: produce a solution to a problem using a IPO chart with either pseudocode or flowcharts used in the processing column.

  •  C++ input and output:  cin, cout, <<, >>

  •  C++ control structures: if-else, while

  •  C++ operators: produce applications that use C++ arithmetic operators

  •  C++ functions: produce modular applications that use program-defined value-returning C++ functions

Goals: This assignment is designed to reinforce the student’s ability to implement solutions to problems using the sequential , selection and repetition control structures and program-defined value-returning C++ functions.

Outcomes: Students successfully completing this assignment would master the following outcomes.

  • Produce an algorithm to solve a problem given the problems specifications.

  • Produce programs that use C++ input and formatted output

  • Produce programs that use C++ selection

  • Produce programs that use C++ repetition with sentinel controlled loops, counters and accumulators

  • Produce programs that use C++ program-defined functions

Description

You are required to write a program that calculates the income tax due for a number of persons. For each person you are required to input the following data:

 
  • national registration number
  • gross salary amount 
  • PAYE paid
  • total deductions

For each person
after getting the input values, your program should calculate the taxable income, which is:

taxable income = gross salary – deductions

The tax due is then calculated as:

25 % on taxable income up to 35,000

40 % on any amount over 35,000

E.g. If the taxable income is $40,000 then the tax due will be:

25% of $35,000 + 40% of $5000

= $8750 + $2000

= $10,750

The tax payable is then calculated by subtracting the PAYE paid from the tax due.

If the difference is less than zero then the person gets a refund otherwise the tax is payable.

For each person the program should display the results in the following format:

Nat Reg.#.: xxxxxxxxxx    Gross Income: $ xxxxx.xx   

Total Deductions: $ xxxxx.xx Taxable Income: $ xxxxxx.xx

Tax/Refund Due: $ xxxxx.xx

The program should continue to prompt the user for the input data until a value of  "XXX" is entered for the National Registration Number. i.e. "XXX" is the sentinel value.

When this value is entered the program should display the following information:

  1. the number of persons receiving a refunds

  2. the total of all the refunds

  3. the number of persons who have to pay taxes

  4. the total of all the tax payable.

Rather than writing all of the code in the main() function, implement and use the following functions:

  1. A function named getNatRegNum that prompts the user to enter a national registration number, stores it in a string variable and returns the value entered by the user. The function receives no actual arguments.

  2. A function named getGross that prompts the user to enter a value for the gross pay, stores it in a double variable and returns the value entered by the user. The function receives no actual arguments.

  3. A function named getPAYE that prompts the user to enter a value for the PAYE, stores it in a double variable and returns the value entered by the user. The function receives no actual arguments.

  4. A function named getDeductions that prompts the user to enter a value for the total deductions, stores it in a double variable and returns the value entered by the user. The function receives no actual arguments.

  5. A function named taxableIncome that receives two double parameters: gross and deductions, calculates the taxable income and returns the result.

  6. A function named taxPayable that receives a double parameter representing the taxable income, calculates the tax payable and returns the result..

 

Submit the following:

The well documented and formatted C++ source code in computer readable format.

 
 
 
« go back|print