How to Write Pseudocode to Calculate Tax

by Jeffrey Ober

Pseudocode is nothing more than a set of steps or a plan on how you will write computer code to complete a task. There is no specific format, and there are no syntax rules for how to write pseudocode. The primary requirement is that the pseudocode writer must be able to understand what to do and when to do it. Pseudocode is very useful for planning complex tasks, such as calculating the tax on a paycheck.

Write your input sources for calculating tax. You need to decide how the inputs will be received by the program. Will the user type them into boxes? Are they standard numbers that are predefined (such as 40 hours a week)? For example, your pseudocode might say this: Get hours and rate from text boxes.

Calculate the gross pay. You will likely be storing the gross pay in a variable, so your pseudocode might read as follows: Store hours times rate in gross pay variable (dblGrossPay).

Subtract pretax deductions. If your paycheck is going to have medical or other deductions that are not taxable, be sure to subtract them to determine your taxable amount. Your pseudocode might look like this: Subtract 401k deductions and store result in pretax variable (dblTaxable).

Determine the amount of income tax to be paid using tax tables. The method of taxation may be different in different areas, so consult your tax tables to determine which bracket or percentage should be used. For example, if dblTaxable is less than 1,000, use tax rate 1; if dblTaxable is less than 2,000, use tax rate 2.

Determine other taxable amounts based on set rates. If you need to consider set tax rates, such as state income tax and Social Security tax, just use the set rates for those. Your pseudocode might say this: State tax equals dblTaxable times 5 percent, stored in dblStateTax.

Calculate the sum of all the taxes (and deductions). If you need to know the total amount taxed, you can just sum all the various taxes. For example, total tax equals dblStateTax plus dblSocialSecurityTax plus MedicareTax.

Calculate the net pay if desired by subtracting all the deductions from the gross pay: Net Pay equals dblGrossPay minus totalTaxes minus otherDeductions.

Video of the Day

Brought to you by Techwalla
Brought to you by Techwalla

About the Author

Jeffrey Ober is a full-time freelance writer with over 20 years of experience with computers and the computer industry, and 10 years of experience in education. He has a master's degree in information systems and is also a professional sports photographer.

More Articles