Re: Please help!
- From: dharajsmith@xxxxxxxxx
- Date: Fri, 26 Oct 2007 22:16:08 -0700
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;
}
.
- Follow-Ups:
- Re: Please help!
- From: Willem
- Re: Please help!
- From: Malcolm McLean
- Re: Please help!
- References:
- Please help!
- From: dharajsmith
- Re: Please help!
- From: user923005
- Please help!
- Prev by Date: Re: Please help!
- Next by Date: Vector problem? - How can I make the faster?
- Previous by thread: Re: Please help!
- Next by thread: Re: Please help!
- Index(es):
Relevant Pages
|