Winter 2019 ECE 102 Engineering Computation Problem #1 Many large companies encourage employees to save by matching their contributions to a 401(k) plan. The government limits how much you can save in these plans, because they shelter income from taxes until the money is withdrawn during your retirement. The amount you can save is tied to your income, as is the amount your employer can contribute. Of course, the government will allow you to save additional amounts, but without the tax benefit. Suppose the Quality Widget Company has the savings plan described in the table below. Percentage P (in %) Amount You Want to Save Tax Free | Maximum the Company will Match (in %) Income (capped at 10% by government) Up to $30 000 Category A: [0, 30k] Between $30 000 and $60 000 P Category B: (30k, 60k Between $60 000 and $100 000 P of the first $60 000 and 0.8P of P of the first $30 000 and 0.5P of Category C: (60k, 100k] P of the first $30 000 and 0.5P of the amount above $30 000 the amount between $30 000 and $60 000; nothing for the remainder above $60 000 the amount above $60 000 P of the first $60 000 and 0.8P of Nothing-highly compensated the amount between $60 000 and employees are exempt from this 100 000; nothing on the amount plan and participate in stock above $100 000 Above $100 000 Category D: (100k, ?] options instead Note: For the salary ranges, parentheses (or) mean that value is not included, while brackets [ or ] mean the value is included. For example, (30k, 60k] is a salary strictly greater than $30k but less than or equal to $60k. Since the calculations are somewhat tedious to do manually (see following examples), it is desirable to finda way to automate the process of determining the contribution amounts. Example #1 Suppose Jane makes $25 000 a year and wants to contribute 6% of her salary to her 401(k) savings plan. Since P-6%, then P-P/ 100-006 (decimal fraction equivalent). Money contributed by Jane: $25 000 x 0.06 $1500 Hence, $1500 will be deducted from Jane's salary and put into the 401(k). The Quality widget Company will match her 6% contribution, so it also contributes $1500 to her 401(k). Note: Some financial experts say this is equivalent to getting "free money:" since the company is matching your contribution as one of your job benefits The total yearly contribution is S1500+$1500-$3000. Winter 2019 ECE 102 Engineering Computation Example #2 Suppose John has a salary of $52 500 per year and will contribute 4% of it to his 401(k). Here P-4%, sop-P / 100 0.04. Money contributed by John: $52 500 x0.04-$2100 Example #2 Suppose John has a salary of $52 500 per year and will contribute 4% of it to his 401(k). Here P 4%, so p P / 100 004. Money contributed by John: $52 500 x 0.04 $2100 The company matches the first $30k at 4%: $30 0002x 0.04-$ 1200 It matches the amount above $30k at (05)(4%): ($52 500-530 000) x (0.5)(0.04)s $450 So, the company's contribution is $1200 $450-$1650. The total yearly contribution is $2100 $1650 $3750. Example #3 Suppose Casey's salary is $87 000 per year and 10% of it is contributed to the 401(k). Since P-10%, this means p P / 100 0.1 0. Casey's first $60k is calculated at 10%: $60 000 x 0.10-S6000 The amount above $60k uses the (0.8)(10%) rate: ($87 000-$60 000) x (0.8)(0.10) Casey's contribution is $6000+$2160-$8160 $2160 The Quality Widget Company matches the first $30k at 10%; S30 000 x 0.10-S3000 Between $30k and $60k, it contributes at (0.5)(10%): (S60 000-S30 000JX (0.5)(0.10) : si 500 The amount above $60k is not matched at all. The company's contribution is $3000+$1500 $4500. The total yearly contribution is $8160+$4500 $12 660. Required Tasks Design and write a MATLAB function named savings401k that meets these specifications: Accepts the employee's salary (in $) and the percentage to contribute (in %) as input arguments. Calculates the contributions (in $) by the employee and the company. o Use the given table as a reference for the salary ranges. o Use appropriate selection statements, e.g.. if-end or if-elseif-end o Be careful how you define your ranges for the selection statements o Consider carefully which equations to use for each situation. o Use good variable names to remind you of their purpose in the equations. Returns the calculated contributions (employee, company, and total) as output arguments Create a MATLAB script that tests your function. These are the requirements: Within a loop: o Prompt the user to enter his or her salary (in S). Allow the user to quit (i.e., exit the loop) by entering a zero (0) for the salary. Prompt the user to enter the percentage (in %) to contribute. Call the savings401k function to do the actual calculations. Display the returned results to the command window to two (2) decimal places. o o Save your script file using this file name: hw4x1.m . Sample run in the command window Enter your yearly salary (in USD or e to quit) 25000 Enter the percentage you wish to contribute (in %): 6 Employee contribution $1500.00 Company contribution $1500.00 Total 401(k) savings $3000.00 Enter your yearly salary (in uSD or e to quit) 52500 Enter the percentage you wish to contribute (in %): 4 Employee contribution $2100.00 Company contribution $1650.00 Call the savings401k function to do the actual calculations. Display the returned results to the command window to two (2) decimal places. o o Save your script file using this file name: hw4x1.m Sample run in the command window Enter your yearly salary (in USD $ or e to quit) 25e00 Enter the percentage you wish to contribute (in %): 6 Employee contribution $1500.00 Company contribution $1500.00 Total 401(k) savings$300e.e0 Enter your yearly salary (in USD $ or e to quit) 52500 Enter the percentage you wish to contribute (in %): 4 Employee contribution $2100.00 Company contribution $1650.00 Total 401(k) savings = $3750.00 Enter your yearly salary (in USD or e to quit) 87000 Enter the percentage you wish to contribute (in %): 10 Employee contribution $8160.08 Company contribution $4500.00 Total 481(k) savings$12660.00 Enter your yearly salary (in USD $ or e to quit) e