Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This homework has two 'parts':
- 1) the specification, or the part you put above the main() and where you actually define your function
- 2) the what to do in main(), or where you actually use the function to test it out
- Function name: RollDice
- Specification: RollDice has one parameter, numRolls, representing the number of times to roll. The function simulates rolling a 20-sided die (i.e. picking a random number from 1 to 20) repeatedly, N times, printing the number each time. Using a running total, it also prints the sum of all N rolls.
- What to do in main(): Ask the user how many times to roll the dice, then call the function using that information.
- Function name: FallingDistance
- Specification: FallingDistance has one parameter, representing a number of seconds.
- When the function runs, it must print a table of time and distance, up to the given number of seconds.
- The formula is distance = 4.9 * (time)2
- What to do in main(): Ask the user for a number of seconds. Then call the function using that information.
- Example run — assuming the user types 3:
- How many seconds? 3
- Time Distance
- 1 s 4.9 m
- 2 s 19.6 m
- 3 s 44.1 m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement