Cuyahoga Community College Passing the Dice Rolling Method Lab 13
Cuyahoga Community College Passing the Dice Rolling Method Lab 13
For this lab, start with the method you created for lab 12. Then:
- Instead of having the method roll two dice and returning the resulting total, have the method require that the calling program tells it how many dice to roll.
- The method will then roll however many dice it is told to roll, and returns that value instead.
- In the main program, ask the use to type in how many dice the ‘rollDice’ method should roll.
Hints:
- Because the method has no way of knowing how many dice it will roll, you will have to create a loop that goes from 0 to the number of gets passed to the method.
- Then, for each iteration of that loop, generate one random number between 1 and 6, and add it to a running total.
- So, before starting the loop, you will want to create a variable, perhaps called total, and set it to 0.
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


