Advertisement
kvarjoy

C++ Homework 3

Mar 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. This homework has two 'parts':
  2. 1) the specification, or the part you put above the main() and where you actually define your function
  3.  
  4. 2) the what to do in main(), or where you actually use the function to test it out
  5.  
  6. Function name: RollDice
  7. 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.
  8.  
  9. What to do in main(): Ask the user how many times to roll the dice, then call the function using that information.
  10.  
  11. Function name: FallingDistance
  12. Specification: FallingDistance has one parameter, representing a number of seconds.
  13. When the function runs, it must print a table of time and distance, up to the given number of seconds.
  14.   The formula is distance = 4.9 * (time)2
  15.  
  16. What to do in main(): Ask the user for a number of seconds. Then call the function using that information.
  17. Example run — assuming the user types 3:
  18. How many seconds? 3
  19. Time Distance
  20. 1 s  4.9 m
  21. 2 s  19.6 m
  22. 3 s  44.1 m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement