Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Savings after 30 years 3 Problem 4: For Problem 3 above, use a for loop to plot the accumulated savings for all 30 years (see

image text in transcribed
image text in transcribed
image text in transcribed
Savings after 30 years 3 Problem 4: For Problem 3 above, use a for loop to plot the accumulated savings for all 30 years (see right plot). Store the accumulated savings in a vector inside the loop and plot versus a years vector of the same length. #define years and days vector, finalday - days (end); initialize the loop starting with day 1 penny added savings - 1; first day saves 1 penny t=1; start on day 1, +1 penny/day calculate savings is an array index going from 2: tinalday for 1 - 2 finalday t=t+1; add additional penny to teach day savings () - savings (3-1) + ti end Seved 10 15 Yeon Extra Credit Problem 1: Pascal's triangle is an array with many unique mathematical properties. It is generated by adding the two numbers above an entry together, resulting in the following pattern. Write a script that requests the number of rows from the user and then generates the requested rows of Pascal's Triangle (format correct numerical pattern in a matrix padded with zeros, see below right). 1 4 9 11 12 1 6 o 0 0 0 + 1 1 1 1 1 1 OO- 2 0 1 2 3 4 5 6 7 0 0 DOOOO 10 0 0 a o 0 1 2 13 1 3 1 461 4 5 1 10 10 # 1 6 7 #1 219 35 11 11 8 9 1.86 70 61 10 INH136 136 H. 11 110 45 120 110 22 118 120 45 10 12 3 0 0 1 3 6 10 15 21 26 36 45 5 0 0 0 0 1 5 15 35 70 126 210 OOOOOOO DODO 0 9 1 10 20 35 56 84 120 1 6 21 56 126 252 1 1 1 7 28 84 0 0 1 0 0 0 1 1 9 45 36 9 10 10 Problem 3: Consider the following simple savings plan. On Day I you put aside one penny. On Day 2, you put aside two pennies. On Day 3 you put aside three pennies. You continue this simple savings plan for several years. How much money do you think you will have in 30 years? Make a guess! Write a script using a while loop 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 365 days per year. Use your function to write the following as an fprintf statement. 'Over 30 years, your accumulated savings is Y and your final contribution is X. Where Y is the total accumulated savings and X is the final day contribution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions