Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Katie wants to calculate how many cups it would take her to make a 2D pyramid of cups, based on how many rows the pyramid

image text in transcribed

Katie wants to calculate how many cups it would take her to make a 2D pyramid of cups, based on how many rows the pyramid has. For example, a one-level pyramid would have a lovel of just one cup, but a two-level pyramid would have a bottom loval of two cups with one cup on top for a total of 3 cups. If another layer of three cups was added below that the total would come to 6 cups (as in the picture below) Katie isn't sure how big of a pyramid she wants, and thus she doesn't know how many cups she needs to buy so she wants to write a program to calculate the different level pyramid possibilities and store them in a vector Write a solution to Kate's problem using a WHILE op and a FOR 10cp ane nested inside the other to add up the number of cups from loval 1 to lovel L The total number of cups in the pyramid for a given level would be stored in the low vector to Cups In other words, this is a cummation problem. Each Index In totcup is the cum of the oups in that level and the levelt above. Example L=4 the pyramid could have up to 4 levels 1 = 1 I=2 Cups 1) = 1 ttups 2) = 1+2 tot Cups/3) = 1+2+3=6 1 = 3 1 = 4 tot Cups/4)= 1+ 2+ 3+ 4 = 10 tot Cups = 11,3,6, 107 Fill in the missing code! (NOTE: there are more efficient ways to do this in MATLAB but the point of this problem is to use NESTED loops!). Do NOT use the built-in function sum) in this code first blank spac: What is the lost condition of the while loop? . second blank space how istocupa updated . third blank space: how is the white loop variable updated? L = randi ([0, 101, 1, 1); totcups eros (1,L): for i=1:1 j=1; floop variable initialized whilej totcups (i) totoups (i) + Supdate the loop variable end end Best Solution Solution 1: 0 of 5 tests passed Submitted on 16 Feb 2020 at 23:11 | ID: 19519241 Size: 0 L = randi(14.10). 1, 1); totcups - ros(1.): 2 1 - 1; loop variable initialized while 1 tot Cups(s) - totcups(s) + 1 update the loop variable

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago