Prev: Designing fgetline - a perspective
Next: ggg supplier ( paypal accept ) ( www.sneaker-fan.com ) ggg shirt supplier ( paypal accept ) ( www.sneaker-fan.com )
From: dharajsmith on 26 Oct 2007 23:34 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 %
From: user923005 on 26 Oct 2007 23:43 On Oct 26, 8:34 pm, dharajsm...(a)yahoo.com 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.
From: dharajsmith on 27 Oct 2007 01:16 On Oct 26, 10:43 pm, user923005 <dcor...(a)connx.com> wrote: > On Oct 26, 8:34 pm, dharajsm...(a)yahoo.com 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; }
From: Malcolm McLean on 27 Oct 2007 03:31 <dharajsmith(a)yahoo.com> wrote in message news:1193462168.142195.86180(a)o80g2000hse.googlegroups.com... On Oct 26, 10:43 pm, user923005 <dcor...(a)connx.com> wrote: > On Oct 26, 8:34 pm, dharajsm...(a)yahoo.com 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
From: Willem on 27 Oct 2007 05:38
<dharajsmith(a)yahoo.com> wrote: )> > 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. ) <snip> ) ) There's no specific language. This class is just beginning ) programming. It's called "Fundamentals of programming with algorithms ) and logic." ) ) Is this correct? ) ) <snip> Malcolm wrote: ) 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. Where do you see that in the assignment ? You're making a simple assignment needlessly complex. It's a 'fundamentals of programming' course, ferchrissake. ) 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 This is bad programming form in any case. Especially when using C++ SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT |