use Matlab, and write entire script Problem 5: Consider the following simple sav
ID: 2086959 • Letter: U
Question
use Matlab, and write entire script
Problem 5: Consider the following simple savings plan. On Day 1 you put aside one penny. On Day 2, you put aside two pennies. On Day 3 you put aside three pennies. You continue this siopke savings plan for several ycarts. How much money do you think you will have in 30 years? Make a guess: Write a script that will compute the amount of money accumulated for a specified number of years. The input to your program will be number of years. The outputs of your program will be the amount of money saved (in dollars, not pennies) and the amount of money contributed on the very last day of your savings plan (in dollars, not pennies). Note: Don't worry about leap years -just assume 363 days per year. Use your function to complete the following table: Years for Savings Plan 20 30 40 Accumulated SavingsContribution on Final DayExplanation / Answer
clear all;close all;commandwindow;clc;
years=input('Enter the number of years in your savings : ');
Days=years*365;
Total_amt_saved=(Days*(Days+1))/2;
Total_Amount_inDollars=Total_amt_saved*0.01;
Amt_saved_LastDayDollars=Days*0.01;
fprintf('You have saved %f Dollars in %d years ',Total_Amount_inDollars,years);
fprintf('You have contributed %d Dollars on the last day of your savings ',Amt_saved_LastDayDollars)
OUTPUT:
Years for savings plan
Accumulated savings
Contribution on final day
20
266486.5
73
30
599567.25
109.5
40
1065873
146
Years for savings plan
Accumulated savings
Contribution on final day
20
266486.5
73
30
599567.25
109.5
40
1065873
146
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.