Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Apologies if this task seems like a lot, I am currently having trouble with making this all work. I've posted my MatLab attempt. Required Tasks
Apologies if this task seems like a lot, I am currently having trouble with making this all work. I've posted my MatLab attempt.
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 $) o o o " 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 Save your script file using this file name: hw4x1.m * Sample run in the command window Enter your yearly salary (in USD $ or 0 to quit) 2500e Enter the percentage you wish to contribute (in %): 6 Employee contribution$1500.0e Company contribution-$1500.00 Total 401(k) savings-$3000.00 Enter your yearly salary (in USD $ or 0 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 perc entage you wish to contribute (in %) : 10 Employee contribution -$8160.00 Company contribution-$4500.00 Total 401(k) savings- $12660.00 Enter your yearly salary (in USD $ or 0 to quit) :0 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 (capped at 10% by government) Maximum the Company will Match (in %) Income 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 above $60 000 the amount between $30 000 and $60 000; nothing for the remainder above $60 000 Above $100 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 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), way to automate the process of determining the contribution amounts is desirable to find a Example #1 Suppose Jane makes $25000 a year and wants to contribute 6% of her salary to her 401(k) savings plan Since P-6%, then p P / 100-0.06 (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 $1500 + $1500 $3000 function savings401k (Salary, Percentage, This fuction accepts the employee's salary (in $) and the percentage to contribute (in %) and returns calculated contribut ions. t salary 300 percentage/100) Percentage(Percentage/100) Emp loyeeSalarytPercentage Company -(1x) elseif Salary>30000 salary 60000 salary 1000001 Percentage-( (0.1*60000) + (0.08* (salary-60000)) ) ; Company F0: else if -end 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 $) o o o " 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 Save your script file using this file name: hw4x1.m * Sample run in the command window Enter your yearly salary (in USD $ or 0 to quit) 2500e Enter the percentage you wish to contribute (in %): 6 Employee contribution$1500.0e Company contribution-$1500.00 Total 401(k) savings-$3000.00 Enter your yearly salary (in USD $ or 0 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 perc entage you wish to contribute (in %) : 10 Employee contribution -$8160.00 Company contribution-$4500.00 Total 401(k) savings- $12660.00 Enter your yearly salary (in USD $ or 0 to quit) :0 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 (capped at 10% by government) Maximum the Company will Match (in %) Income 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 above $60 000 the amount between $30 000 and $60 000; nothing for the remainder above $60 000 Above $100 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 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), way to automate the process of determining the contribution amounts is desirable to find a Example #1 Suppose Jane makes $25000 a year and wants to contribute 6% of her salary to her 401(k) savings plan Since P-6%, then p P / 100-0.06 (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 $1500 + $1500 $3000 function savings401k (Salary, Percentage, This fuction accepts the employee's salary (in $) and the percentage to contribute (in %) and returns calculated contribut ions. t salary 300 percentage/100) Percentage(Percentage/100) Emp loyeeSalarytPercentage Company -(1x) elseif Salary>30000 salary 60000 salary 1000001 Percentage-( (0.1*60000) + (0.08* (salary-60000)) ) ; Company F0: else if -endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started