Prev: Designing fgetline - a perspective
Next: ggg supplier ( paypal accept ) ( www.sneaker-fan.com ) ggg shirt supplier ( paypal accept ) ( www.sneaker-fan.com )
From: Willem on 27 Oct 2007 05:41 dharajsmith(a)yahoo.com wrote: ) 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; ) <snip> The assignment also said to test it. If you did, you should know if it works or not, right ? It seems okay to me, by the way. I'm curious, what are you going to do in IT that doesn't involve programming skills ? 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
From: Willem on 27 Oct 2007 05:52 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. ) ) 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 could do it in SQL, by the way. Put the above figures in a table, put the salaries in another table, and then you can calculate the result with a single SELECT statement. Something like: SELECT s.salary, t.base + ((s.salary - t.min_range) * t.tax) AS tax FROM tax_table t, salary_table s WHERE s.salary >= t.min_range AND s.salary <= t.max_range As you can see, picking the right language/tool makes the solution a lot easier. (Even though your instructor will probably not accept this, what with it being a programming course, and SQL only barely qualifying as a programming language...) 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
From: jimmaureenrogers on 28 Oct 2007 00:08 On Oct 26, 9: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 % A simple solution based upon a table look up follows. The solution is written using Ada. Obvious enhancements to this solution include ensuring the input salary is not less than 0 and not more than 14999.99. --- -- Tax calculation exercise --- with Ada.Text_Io; use Ada.Text_Io; with Ada.Float_Text_Io; use Ada.Float_Text_Io; procedure Tax_Calc is type Tax_Rate is record Salary_Min : Float; Salary_Max : Float; Base_Tax : Float; Excess_Rate : Float; end record; Tax_Table : constant array(1..5) of Tax_Rate := ( (Salary_Min => 0.0, Salary_Max => 1_499.99, Base_Tax => 0.0, Excess_Rate => 0.15), (Salary_Min => 1_500.00, Salary_Max => 2_999.99, Base_Tax => 225.0, Excess_Rate => 0.16), (Salary_Min => 3_000.00, Salary_Max => 4_999.99, Base_Tax => 465.0, Excess_Rate => 0.18), (Salary_Min => 5_000.00, Salary_Max => 7_999.99, Base_Tax => 825.0, Excess_Rate => 0.20), (Salary_Min => 8_000.00, Salary_Max => 14_999.99, Base_Tax => 1_425.0, Excess_Rate => 0.25)); Input_Salary : Float; Total_Tax : Float; begin Put("Enter the salary: "); Get(Item => Input_Salary); for I in Tax_Table'range loop if Input_Salary >= Tax_Table(I).Salary_Min and Input_Salary <= Tax_Table(I).Salary_Max then Total_Tax := Tax_Table(I).Base_Tax + ((Input_Salary - Tax_Table(I).Salary_Min) * Tax_Table(I).Excess_Rate); exit; end if; end loop; Put("Tax for salary of "); Put(Item => Input_Salary, Aft => 2, Exp => 0); Put(" is "); Put(Item => Total_Tax, Aft => 2, Exp => 0); New_Line; end Tax_Calc; Jim Rogers
From: jellybean stonerfish on 29 Oct 2007 13:24 On Fri, 26 Oct 2007 20:34:15 -0700, dharajsmith 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 No. Not if it was due on Friday night. But I will give it a try. You are working too hard! · Design a program that solves this problem. I took that to mean "Design a Program". Not write the code. · Generate a set of input test values. Here you make a list of random amounts in the range and some out of the range (to test handling exceptional values) With the answers. Not generated by the program. This is test data, to test the program. You would use a known working method to generate this data. · Perform a design walkthrough to verify your design. Here you do a walk-through. Take a subset of your test data incomes, and item by item follow your design ( flow chart or whatever ) step by step, solving for the tax amount. Compare the results to the answers in you test data, and wrap it in a nice cover page. stonerfish
From: jellybean stonerfish on 29 Oct 2007 13:26
On Sat, 27 Oct 2007 21:08:30 -0700, jimmaureenrogers(a)worldnet.att.net wrote: > A simple solution based upon a table look up follows. The solution is > written using Ada. Am I the only one who read the assignment? sf |