Re: Please help!




<dharajsmith@xxxxxxxxx> wrote in message news:1193462168.142195.86180@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Oct 26, 10:43 pm, user923005 <dcor...@xxxxxxxxx> wrote:
On Oct 26, 8:34 pm, dharajsm...@xxxxxxxxx wrote:





> I am a student at Axia College. I have an assignment due tonight,
> that I do not have a clue how to do. I am not going into Programming,
> but this class is a required class to go on to the next classes in
> IT. Can someone please help.

> Here is the assignment:

> You are an accountant setting up a payroll system for a small firm.
> Each line of the table in Appendix G (posted below) 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.

> Appendix G:

> 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 0.00-1,499.99 0.00 15 %
> 2 1,500.00-2,999.99 225.00 16 %
> 3 3,000.00-4,999.99 465.00 18 %
> 4 5,000.00-7,999.99 825.00 20 %
> 5 8,000.00-14,999.99 1425.00 25 %

You did not say what language your assignment is supposed to be in.
So answers cannot be direct.

I suggest that you start by:

0. Given a salary amount (collect a salary amount from the user or a
file)
1. tax is calculated by adding the base tax for that salary range
(lookup base tax from a table)
2. and the product of percentage of excess (lookup % excess from your
table)
3. and the amount of salary over the minimum salary for that range.
(lookup amount over the minimum)
4. Calculate the number given these 4 facts.
That takes care of this:
· Design a program that solves this problem.

Your sample table gives you 10 test values. Try some others.. just
use your head. That handles this:
· Generate a set of input test values.

Show that the program works. That handles this:
· Perform a design walkthrough to verify your design.- Hide quoted text -

- Show quoted text -

There's no specific language. This class is just beginning
programming. It's called "Fundamentals of programming with algorithms
and logic."

Is this correct?

#include <iostream>
using namespace std;

int main(int argc, char **argv){
double salary;
double taxrate;
double tax;

//get input
cout<<"Enter Salary: ";
cin >> salary;

//compute tax and type of salary
if(salary >=0 && salary <1500){
tax = salary * 0.15;
cout<<"Salary is: $" << salary<<endl;
cout<<"Tax is: $"<<tax <<endl;
cout<<"Net Salary is: $"<< (salary - tax)<<endl;
}
else if(salary >=1500 && salary <3000){
tax = 225.0;
double x = salary - 1500;
tax += x * 0.16;
cout<<"Salary is: $" << salary<<endl;
cout<<"Tax is: $"<<tax <<endl;
cout<<"Net Salary is: $"<< (salary - tax)<<endl;
}
else if(salary >=3000 && salary < 5000){
tax = 465.0;
double x = salary - 3000;
tax += x * 0.18;
cout<<"Salary is: $" << salary<<endl;
cout<<"Tax is: $"<<tax <<endl;
cout<<"Net Salary is: $"<< (salary - tax)<<endl;
}
else if(salary >=5000 && salary <8000){
tax = 825.0;
double x = salary - 5000;
tax += x * 0.20;
cout<<"Salary is: $" << salary<<endl;
cout<<"Tax is: $"<<tax <<endl;
cout<<"Net Salary is: $"<< (salary - tax)<<endl;
}
else if(salary >=8000 && salary <15000){
tax = 1525.0;
double x = salary - 8000;
tax += x * 0.25;
cout<<"Salary is: $" << salary<<endl;
cout<<"Tax is: $"<<tax <<endl;
cout<<"Net Salary is: $"<< (salary - tax)<<endl;
}


system("pause");
return 0;
}


No, I'm afrid you've haven't really understood.

The program needs to read a table of salaries and tax rates from an input file.
If you are implementing in C++ unfortunately it is hard to give an answer because there are so may styles of C++ programming.

Basically you need

#define MAXBRACKET 1000

We can assume that no mad bureaucrat would ever have over 1000 tax bands.

double minsal[MAXBRACKET];
double maxsalary[MAXBRACKET];
doube taxrate[MAXBRACKET];
int Nbrackets;

So we set up this global array, and read the values from the table into it.
So Nbrackets will be set to the number of data lines in the table (read until you get an EOF, incrementing each time).

As a test, print out these arrays to make sure you have read them in correctly.

Then it is a simple matter of taking the salary, stepping through the array until you are greater than or equal to the minimum and less than or equal to the maximum. Then apply your tax formula.


--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm



.



Relevant Pages

  • Re: Please help!
    ... I am not going into Programming, ... employee's salary range and corresponding base tax amount and tax ... Given a salary amount, the tax is calculated by adding the ... · Design a program that solves this problem. ...
    (comp.programming)
  • Re: [SLE] Possible to do taxes in Linux? (Canada)
    ... for tax submissions is straightforward. ... the content must be done with knowledge of the software framework as ... it's far from trivial to encode tax laws. ... knowledge of spreadsheet, database or GUI programming. ...
    (SuSE)
  • Re: Please help!
    ... )>> employee's salary range and corresponding base tax amount and tax ... Perform a design walkthrough to verify your design. ... It's called "Fundamentals of programming with algorithms ... Where do you see that in the assignment? ...
    (comp.programming)
  • Re: Veritas 8C manuals
    ... If you have kept the sensors in the same place the panel will have the same ... programming as when you powered it down and will work the same. ... there was two different versions of that panel and they program differently. ... A fine is a tax for doing wrong. ...
    (alt.security.alarms)
  • Re: How unemployment hits the middle classes
    ... Paying 'enormous amounts of tax' is no measure of effort, ... My father probably didn't pay an enormous amount of tax in his ... paid very little tax, but then again he was paid 'very little' anyway - ... because up until yesterday Tesco were only refunding the ...
    (uk.politics.misc)