# anyone want to help on a class that I am having to take for programming?

Discussion in 'BlackHat Lounge' started by CenTex Hosting, Nov 13, 2010.

1. ### CenTex HostingJr. VIPJr. VIP

Joined:
Nov 8, 2009
Messages:
1,823
688
Gender:
Male
Occupation:
Location:
Austin, TX
I am an seo and MySql Guy not a regular programmer but I have to take this basic class to finish out another degree that I am working on. Willing to give a thanks and rep if you can help out tonight

You are an accountant setting up a payroll system for a small firm. Each line of the table in Appendix G indicates an employee’s salary range and corresponding base tax amount and tax percentage. Given a salary amount, the tax is calculated by adding the base tax for that salary range and the product of percentage of excess and the amount of salary over the minimum salary for that range.

· Design a program that solves this problem.
· Generate a set of input test values.
· Perform a design walkthrough to verify your design.

Sequential and Selection Process Control Structure
In the following example, the second line of the table specifies that tax due on a salary of \$2000.00 is \$225.00 plus 16% of excess salary over \$1500.00 (that is, 16% of \$500.00). Therefore, the total tax is \$225.00 + \$80.00, or \$305.00.

Salary Range in Dollars
Base Tax in Dollars
Percentage of Excess
1. 1
0.00-1,499.99
0.00
15 %
2. 2
1,500.00-2,999.99
225.00
16 %
3. 3
3,000.00-4,999.99
465.00
18 %
4. 4
5,000.00-7,999.99
825.00
20 %
5. 5
8,000.00-14,999.99
1425.00
25 %

2. ### imperial109Regular Member

Joined:
Jan 19, 2009
Messages:
499
361
What language are you looking for it to be programmed in?

3. ### CenTex HostingJr. VIPJr. VIP

Joined:
Nov 8, 2009
Messages:
1,823
688
Gender:
Male
Occupation:
Location:
Austin, TX
thats the problem is it doesnt have to be programmed just have to write something out saying do this and do that to get this

Sequential and Selection Process Control Structure

4. ### imperial109Regular Member

Joined:
Jan 19, 2009
Messages:
499
361
Use Excel - You can perform calculations with sections of your choosing.

Your college should have a computer lab with Excel 2010. Just go to the "Formulas" tab.

• Thanks x 1
5. ### CenTex HostingJr. VIPJr. VIP

Joined:
Nov 8, 2009
Messages:
1,823
688
Gender:
Male
Occupation:
Location:
Austin, TX
I think this is more along the lines of what they are wanting. I know how to go into excel and make it do the out put as well as using php and mysql but I think this is what they are asking for

1. Get user input - salary range in dollars, the base tax in dollars and the percentage of excess
2. Find excess salary
3. Calculate base tax plus percent of excess
4. Multiply excess of amount by the percentage plus the base tax
5. Calculate total excess tax due Analysis To compute tax due on excess salary (output), one needs to distinguish the salary range in dollars, the base tax in dollars, the percentage of excess by calculating excess of amount by the percentage plus the base tax (input).

TaxDue = BaseTax + Percent * AmountExcess
Where Percent * AmountExcess + BaseTax = TaxDue
Chart 1 Input-Process-Output Chart INPUT PROCESS OUPUT
Salary range in dollars Base tax in dollars Percentage of excess Salary excess TaxDue = BaseTax + PercentExcess * AmountExcess Percent * AmountExcess + BaseTax = TaxDue
Salary range in dollars Base tax in dollars Percentage of excess Input Salary Range, Base Tax, Percentage of Excess, Salary Excess Compute AmountExcess Compute TaxDue Output the input data and tax due on excess salary Prompt Salary Range, Base Tax, Percentage of Excess, Salary Excess Input Salary Range, Base Tax, Percentage of Excess, Salary Excess Set TaxDue = BaseTax + Percent * AmountExcess Set Percent * AmountExcess + BaseTax = TaxDue Write Salary Range Write Base Tax Write Percentage of Excess Write Salary of Excess
Write TotalTax Due on ExcessSalary
Write "What is salary range?" Input SalaryRange
Write "What is base tax, percentage excess, salary excess?"
Input TaxDue Write "The salary range is: ", SalaryRange Write "BaseTax is: ", BaseTax Write "PercentageExcess was: ", Percentage of Excess
Write "SalaryExcess: ", SalaryExcess
Write "TaxDue: ", TaxDue
Write "Total: \$", TotalPrice
Main module Call Input Data module Call Perform Calculations module Call Output Results module End Program Main module Declare SalaryRange As String Declare BaseTax, PercentExcess, AmountExcess, TaxDue As Real Write "Excess Tax Due Program"
Write "This program computes the total tax due,"
Write "including tax due, of an excess salary range that has been"
Write "excess a certain percentage."
Call Input Data module
Call Perform Calculations module
Call Output Results module End program Input Data module
Write "What is the salary range?"
Input SalaryRange
Write "What is its base tax, percentage excess and the amount excess?"
Input BaseTax, PercentExcess, AmountExcess Perform Calculations module Declare SalaryRange As Real Set TaxDue = BaseTax + PercentExcess * AmountExcess Set Percent * AmountExcess + BaseTax = TaxDue Set TotalPrice = TaxDue Output Results module
Write "The salary range is: ", SalaryRange
Write "Base tax is: ", BaseTax Write "Base tax is: ", PercentExcess Write "Percent excess is: ", AmountExcess
Write "Tax due is: ", TaxDue Input values \$465 + \$90, or \$550 tax due on salary of \$3,500 \$465 + \$180, or \$645 tax due on salary of \$4,000 \$825 + \$100, or \$925 tax due on salary of \$5,500 \$825 + \$200, or \$1025 tax due on salary of \$6,000 \$1425 + \$125, or \$1550 tax due on salary of \$8,500 \$1425 + \$250, or \$1675 tax due on salary of \$9,000

6. ### TwizzlerNewbie

Joined:
Nov 4, 2010
Messages:
33
7
Occupation:
Typing code.
Location:
Lost in cyberspace
psuedo?

for each salary in table
do
if salary <= 1499.99
totaltax = salary * .0.15
elseif salary >= 1500 and salary <= 2999.99
totaltax = 225 + (salary * 0.16)
elseif salary >= 3000 and salary <= 3999.99
totaltax = 465 + (salary * .18)
.... and so on.....
endif

end for

• Thanks x 1
7. ### pyronautExecutive VIP

Joined:
Dec 9, 2008
Messages:
1,229
1,425
I am a C# guy mostly, but also PHP, Perl and whatever else needs to be done. If you were going to do this completely basic, you coull use set of if statements.

Code:
```int Income = GetUserInput();
int TaxBracket; //Specifies which bracket(1, 2, 3, 4)
int MinimumEarnings; //Tax over this  amount
int TaxBase; //Base tax
int TaxPercentage; //Percentage that the tax is.,

if(Income < 1500)
{
TaxBracket = 1;
MinimumEarnings = 0;
TaxBase = 0;
TaxPercentage = 15;
}else if(Income < 2999)
{
//And just do all those steps again.
}

//Once you get down here. You have a set of variables with EVERY number you need. So you can write them out individually like...

console.writeline('Your Tax Percentage is '+TaxPercentage);

//And what have you.
//And from there you have a simple statement

int TotalTax = TaxBase + (Income / 100 * TaxPercentage)

```
The rest you need to put in your own words. This is more theory then anything, and the right answer is going to depend on what they have taught you in class.

• Thanks x 1
8. ### GreyWolfExecutive VIPJr. VIP

Joined:
Aug 17, 2009
Messages:
1,930
5,452
Gender:
Male
Occupation:
Artist / Craftsman
Location:
sitting at my PC
Sounds like something from a Structured Programing class. They're usually concerned about the design structure independent of any language. If you have a good design then a programmer for any launguage should be able to follow the flow chart and write the code.

Looks like your on the right track with how your writing it out. Now you just need to take some sample input and step your way through the structure and see if it would output the correct results.

• Thanks x 1
9. ### tacopalypseExecutive VIPJr. VIPPremium Member

Joined:
Nov 30, 2009
Messages:
983
2,497
hehe, keep it nice and elegant

PHP:
``` <?phpecho calculate(2000);function calculate(\$salary){    \$a = array(        0.00, 1499.99, 0.00, 15,        1500.00, 2999.99, 225.00, 16,        3000.00, 4999.99, 465.00, 18,        5000.00, 7999.99, 825.00, 20,        8000.00, 14999.99, 1425.00, 25    );    for(\$i=0; \$i<count(\$a); \$i+=4){        if(\$salary >= \$a[\$i] && \$salary <= \$a[\$i+1]){            echo \$a[\$i+2] + (\$a[\$i+3]/100) * (\$salary-\$a[\$i]);            break;        }    }}?> ```

10. ### GreyWolfExecutive VIPJr. VIP

Joined:
Aug 17, 2009
Messages:
1,930
5,452
Gender:
Male
Occupation:
Artist / Craftsman
Location:
sitting at my PC
You guys are all trying to code the program in different languages.

@billsboardonline - At it's most basic this is what your looking at
If you need to include the pay level, salary and tax in the output you could include that as well.
If it needs a way to break out of the loop you could include an out of range conditional like
Without being in the same class I can't say if this is what they're looking for, but it follows the instructions as stated in your first post.

If they actually need formatted output or anything like that you would just need to build on this basic structure.

You could also use an array to hold the table, check the inputed data against the pay level, and then use variables in the conditional. (tacopalypse's code really is elegant. Solves the problem with very little code, but it seems like you're looking for just the structure not the code.)

edit- I just noticed Twizzlers reply. His idea seems basically the same as mine too.

Last edited: Nov 13, 2010