The following code simulates the movement of a golf ball in the air after it's been hit. initialVelocity ← 44 accelFromGravity ← -9.8 x ← 0 y ← 0 t ← 0 REPEAT UNTIL (y < 0) { x ← initialVelocity * t; y ← (initialVelocity * t) + ((accelFromGravity * (t*t)) / 2) DISPLAY(x) DISPLAY(y) t ← t + 1 } Which statement best describes why this simulation is an abstraction?
Answer:
It leaves out details that do not effect the results as much, such as air resistance or golf ball material.
Explanation:
A simulation is an abstraction of a complex phenomena that captures the higher-level details that are necessary for the purposes of the simulation and excludes other details.
Imagine you are interested in finding out how much time it takes on average to walk from one end of your school to the next. You’ve decided to figure this out on your lunch break and are able to complete the walk 20 times what would your algorithm look like where could a loop show up? Note: you do not have to write your algorithm in a programming language. You can write it out in English or in pseudocode code
Start a timer at one end of the school.
Walk at a normal pace to the other end of the school while timing the walk with the timer.
Stop the timer once you reach the other end of the school.
Record the time taken to walk from one end of the school to the other.
Repeat steps 1-4 twenty times.
Calculate the average time taken by adding up the recorded times and dividing by 20.
A loop could show up in step 5, where the process of walking from one end of the school to the other and recording the time is repeated 20 times. This could be accomplished using a for loop in a programming language, where the loop would run 20 times, with each iteration representing a walk from one end of the school to the other.