SmartExpert

(118)

$30/per page/Negotiable

About SmartExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Business & Finance See all
Accounting,Business & Finance,Economics,English,HR Management,Math Hide all
Teaching Since: Apr 2017
Last Sign in: 5 Days Ago
Questions Answered: 7559
Tutorials Posted: 7341

Education

  • BS,MBA, PHD
    Adelphi University/Devry
    Apr-2000 - Mar-2005

Experience

  • HOD ,Professor
    Adelphi University
    Sep-2007 - Apr-2017

Category > Computer Science Posted 25 Jul 2019 My Price 8.00

IT 111 Unit 5 Assignment

Assignment Details

Outcomes addressed in this activity: Unit outcomes:

  • Examine the concept of iteration structures.
  • Use For Loops.
  • Use While Loops. 

Course outcome(s) practiced in this unit:

IT111-3: Apply the programming constructs of iteration, assignment and decision-making.

Instructions:

While Loop Tree Growing 

  1. Open Alice3. Set the scene with a tree and a water hole. Select any type of tree that you want to from the gallery. You can create a water hole by using the disc shape, naming it “water”, and setting the color to blue. If your water looks a bit grainy, move the disc up because this means it is down below ground level. Name this program TreeGrows

 

  1. You do not know in this situation how many times the tree is going to grow since it will be based on the size of the water supply. Because the number of executions for the loop is unknown, you will need to use the while loop instead of the for loop. Drag the while loop onto the editor and choose true

 

  1. You want the while loop to be executed as long as there is still water left (based on width of disc shape). You will use a function to determine the disc shape’s width. You need to select the drop down arrow next to true for the while loop and select Relational (Decimal Number), then ??? > ???, then 0.1, and 0.1 as shown below: 

 

  1. Now, select the function for the water, drag the getWidth function for the water onto the first 0.1 for the while loop as shown below. You used 0.1 so that it will stop when the water supply is very close to 0. You did not use 0, because the object will not shrink down to exactly 0 or less then 0, but it will get very close. If you were to use 0, then the animation would never stop since it will never become exactly 0 and the width of an object will not become negative. 

 

  1. Then, inside the while loop, set the width of the water so that it shrinks. You can do this by setting the width as the width minus 0.1. Drag the setWidth procedure for the water onto the editor inside of your loop. You will need to select a number first as a placeholder, then drag the getWidth function from the water onto the placeholder number. After you have this, you can drop down next to the getWidth function, select Math, then select water.getWidth() - ???, and then choose Custom DecimalNumber and type in 0.1

 

  1. Run your code to see what happens. The water shrinks, but the tree does not grow. You need to add the code to make the tree grow as the water supply shrinks. Select the tree and drag the setHeight procedure for the tree under the water setWidth procedure inside the loop. Select a default placeholder for the size. You will need to change this placeholder so that you can get the current size of the tree and add to that current size. To do this you will need to select the getHeight function for the tree and drag this onto the placeholder. Then, you will click on the drop down next to the getHeight function and select Math, then tree.getHeight + ???, and finally choose Custom DecimalNumber and type in 0.1.
  2. Now, the ending code should look as follows: 

 

  1. Run the animation. The water supply should shrink and the tree should grow, then the water supply should shrink, and the tree should grow, this will continue to happen as long as there is water.
  2. Adjust the size of the water supply, does the tree grow taller? Shrink the water supply, does the tree stay short?  Adjust the tree size to see if the animation still works. 

Requirements: 

    1. Create a scene with a tree and a waterhole.
    2. Use a while loop that allows the tree to continue to grow as long as there is still water in the hole.
    3. Use a function (getWidth) to measure state of waterhole.
    4. Use the procedure (setHeight) to make the tree grow as the water supply shrinks.
    5. Use the function (getHeight) to obtain the current size of the tree since it is constantly changing.

Answers

(118)
Status NEW Posted 25 Jul 2019 06:07 PM My Price 8.00

IT -----------111----------- Un-----------it -----------5 A-----------ssi-----------gnm-----------ent-----------

Attachments

1564080371-IT 111 Unit 5 Assignment.zip
Not Rated(0)