Unit 3 Sections 12 and 13 Blog
Unit 3 Sections 12 and 13 Blog
Notes
A procedure call interrupts an execution of statements and makes the program execute the statements in the procedure.
A procedure is a named group of programming instructions that may have parameters and return values.
Arguments specify the values of the parameters when a procedure is called.
If you have a set of statements and inside there is a procedure then when it reaches that procedure it will excute that procedure and then go back to the rest of the statements.
If you have a set of statements in a procedure the statement will go thought the top of the procedure to the bottom in order.
If you see a return statement you automatically end the procedure even if there is more statements
Modularity - the practice of breaking a complex program into smaller, independent parts or modules that can be used and reused in different parts of the program
Parameters are input values of a procedure.
Parameter: are input values of a procedure
Procedures can be referred to as method or function depending on the programing language.
Procedures are that a catch-all term for codes used to identify what was done to or given to a patient
Procedure: is a named group of programming instructions that serves a purpose
There are two types of procedures, one that returns a value or some type of data and on that just executes a block of statements
3.12 Part 1 Hacks
Problem 1
PROCEDURE calcAvgSpeed (distance, time) { DISPLAY (time/distance) }
Problem 2
True==
Problem 3
totalFootprint ← calcFlightFootprint(2451, 118) + calcFlightFootprint(3442, 252)
totalFootprint ← calcFlightFootprint((2451, 118) + (3442, 252))
3.12 Part 2 Hacks
PROCEDURE find a ()
{ c – 9
b <– 9 * 9
a <– b * c
Print (a)
}
What is a?
a= 729
cost ⟵ 173 tax - 10%
PROCEDURE applytax (cost, cpercentDiscounted) { temp <– 100 + percentTaxed
temp <– temp / 100
cost <– cost x temp
Print(cost)}
What is the cost?
cost= $190.30
Tempature - 103 Degrees
PROCEDURE convet Fahrenheit (tempature)
{
Celsius <– tempature - 32
Celsius <– Celsius x 5/9
Print (Celsius)}
temperature: 39.4 degrees Celsius
3.13 Hacks
#1 Create a procedure that is meant to replace the top running backs yards per game in one season if the current running back has more yards per game
Necessary Parameters: toprbyardspg(100), currentrbyards(1260), totalGames(12)
PROCEDURE Replace the top running backs yards per game in one season if the current running back has more yards per game
If (currentRbYards(1260) > toprbyardspg(100)
toprbyardspg <– currentRbYards
#2 Write a procedure that will allow the A+ to get to the 1, while avoiding the black boxes
PROCEDURE GetA+to1
MOVE_RIGHT()
MOVE_RIGHT()
MOVE_FORWARD()
MOVE_RIGHT()
MOVE_RIGHT()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_LEFT()
MOVE_LEFT()
MOVE_LEFT()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_LEFT()
#3 Which Is the Correct Way to define the Name of a Procedure?
A. PROCEDURE MYLIST
B. PROCEDURE MyList
C. procedure mylist
#4 Write A Procedure That gets the BeachBall To the Green Square
PROCEDURE Getballtosquare
MOVE_LEFT()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_FORWARD()
MOVE_LEFT()
MOVE_LEFT()
Reflection
These lessons were a little difficult at first, but with persistence, I was able to grasp the ideas, which enabled me to correctly respond to the questions. I took a lot away from the presentation because it was amazing.