CSci 1001 Problem set 4. Due Tuesday, March 31 at 11:59pm.

Problem 1 (8 points): the sum of random numbers

Write a program that generates 5 rolls of a 6-sided die (in a loop), prints out each roll, and finds and prints out their sum after the loop. Hint: you would need a variable sum that you set to zero before the loop and use to store the running sum of the random numbers.

Problem 2 (8 points): adding random numbers upto a given number

Write a program that keeps generating rolls of a 6-sided die until they add up to 20 or more. Use a 'while' loop and a sum variable, as in the previous problem. Use 'sum' in the condition of the loop. You don't need a loop counter for this problem.

How to submit

Send all of your program files to me by e-mail. You may submit the written part (if any) in class or send it together with your problem set. Please send only ONE e-mail with your entire submission, make sure you include everything. Multiple e-mails with your homework may result in a lower grade.


CSci 1001 course web site.