Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a function called stMs that prints the welcome lines you see below in the sample runs. This is all this function should do.

image text in transcribedimage text in transcribedimage text in transcribed

1. Write a function called stMs that prints the welcome lines you see below in the sample runs. This is all this function should do. The function should not take in any parameters or return any value, 2. Write a function called RollDice that returns the result from rolling two standard six-sided dice) o The function will take no parameters, but it will generate two random die values and return the resulting total of the dice roll as an integer o Reuember that the rolling of a die involves raudomness, so you'll need to use the raudom number geueration fuactious discussed in class (see online notes) Note that rolling two 6-sided dice s NOT equivalent to picking a random number rom 2 through 2 hts is because when vou ro 2 dice, there is a much larger change of hitting some totals than others. You need to roll two dice and add them together. This is the value you'll return. No input or output should occur in this function 3. To test these fiunctions, write a main) routine that does the following: o Calls your startMsg function to welcme the user Enter in a loop to Ask the user to enter how many time they want to roll the dce and them eater a value (forthis writeup 'll call to o Call the RollDice function this many times (i.e. N times), and count how many times a total of 2 (known as "Snake Eyes") appears, how many times a roll of 12 appears, and how many times a total of 7 appears For each of these totals (2,7, and 12)print out how many times that total appeared, as well as what percentage this is of the total uumber of rolls. Perventages should be printed to 2 decimal places. o Do these tasks over and over until the user enters 0 as N to quit. If the user ever enters a negative roll amount, print an error message (see sample uns). 4. Note: When you seed the rando uber getor, you should do so right a the start of main. Also, o ahead and use the tme functio, as illustrated in the class notes. Reember to seed at the beginng of main. and only once in your program. If using CLION, it may suggest for you to use the lirary, just ignore this for now and use the methods we've learned in class Sample Run 1 (user input underlined) Welcome to the dice stats calculator! Let us know how many times to roll the dice! Enter 0 whenever you're ready to quit How many times should we roll the dice? 2000000000 Rolling dice 2000000000 times... Results: A roll of 2 appeared 55563271 total times, 2.78% of the time. A roll of 7 appeared 333299432 total times, 16.66% of the time A roll of 12 appeared 55580988 total times, 2.78% of the time How many times should we roll the dice? > 500 Rolling dice 500 times... Results: A roll of 2 appeared 11 total times, 2.20% of the time A roll of 7 appeared 89 total times, 17.80% of the time A roll of 12 appeared 11 total times, 2.20% of the time How many times should we roll the dice? > 12345678 Rolling dice 12345678 times... Results: A roll of 2 appeared 342145 total times, 2.77% of the time A roll of 7 appeared 2059615 total times, 16.68% of the time . A roll of 12 appeared 343914 total times, 2.79% of the time. How many times should we roll the dice? See ya! Sample Run 2 (user input underlined) Welcome to the dice stats calculator! Let us know how many times to roll the dice! Enter 0 whenever you're ready to quit How many times should we roll the dice? Cannot roll dice a negative number of times How many times should we roll the dice? Rolling dice 1 times... Results: A roll of 2 appeared 0 total times, 0.00% of the time A roll of 7 appeared 0 total times, 0.00% of the time A roll of 12 appeared 0 total times, 0.00% of the time How many times should we roll the dice? > 10 Rolling dice 10 times... Results: A roll of 2 appeared 0 total times, 0.00% of the time A roll of 7 appeared 3 total times, 30.00% of the time A roll of 12 appeared 0 total times, 0.00% of the time How many times should we roll the dice? > See ya! Sample Run 3 (user input underlined) Welcome to the dice stats calculator! Let us know how many times to roll the dice! Enter 0 whenever you're ready to quit. How many times should we roll the dice? > See ya

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions