Find "your number": take your account (ex 750 for s750 ), compute MOD 4, add 1. So for 750, that result is 3
Using a seed value of 11, and 10 rolls of a 4-sided dice, how many times did your number ( ex. 3 ) appear
Program description:
Code in C
Roll a 4 sided dice, 10 times
Count how many of each 1,2,3,4 were observed
C Code:
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
// Driver program
int main(void)
{
int l=1,u=4,i1=0,i2=0,i3=0,i4=0;
srand(time(0));
for(int i = 0; i<10; i++){
int num = (rand() %(u - l + 1)) + l;
if(num==1)
i1++;
else if(num==2)
i2++;
else if(num==3)
i3++;
else
i4++;
}
printf("The 4 sided dice when rolled 10 times has\n1 - %d times\n2 - %d times\n3 - %d times\n4 - %d times\n",i1,i2,i3,i4);
return 0;
}
output-

if you like the answer please provide a thumbs up.
Find "your number": take your account (ex 750 for s750 ), compute MOD 4, add 1....
(1 point) Using an if Statement In a Loop A common thing to do is to use variables to keep track of some sort of count. When used in a loop we count things very quickly. Scenario: If you roll a pair of dice, rolling a 12 (two sixes) is rare. How rare? If you were to roll a pair of dice 1,000 times, on average, how many times would it come up as 12? To figure this out, we...
The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values together. 2. Choose whether to roll the dice again or pass the dice to your opponent. 3. If you pass, then you get to bank any points earned on your turn. Those points become permanent. If you roll again, then add your result to your previous score, but you run the risk of losing all points earned since your...
need help with dice excercise
For example, if we were writing a calendar program of some sort, we might very well use an array with 366 spots to hold the days, not worrying about adding more days to the year. Exercise 23 (C level] For another example, suppose we want to simulate rolling two six-sided dice repeatedly, tallying how many times each total is rolled. We need a memory cell to count the number of times each of the possible...
Problem 9 A single game of craps (a dice game) consists of at most two rolls of a pair of six sided dice. The ways to win are as follows: Win-the first roll of the pair of dice sums to either 7 or 1 (you win, game over, no second roll Win the first roll of the pair of dice does NOT sum to either 7 or 1 but the sum of the second roll is equal to the sum...
Can anyone help me with this java program? We are still very early with lessons so no advanced code please. And if you comment throughout the code that would be incredibly helpful. Thank you Create 2 Java files for this assignment: Die.java and TestDie.java Part 1 - The Die Class The program Design a Die class that contains the following attributes: sides: represents how many sides a dice has. A dice usually has 6 sides but sometimes could have...
Exercise I: More dice rolls You repeatedly throw a dice. 1. Compute the probability of the following events. Write these events precisely using other events, and say where you use assumptions such as independence or disjoint- ness. Give your results as a single simplified fraction. (a) The first roll is even and the second one is odd. (b) The first five rolls are even. (c) The first roll is even and the second one is odd, or the first roll...
(CO 4 and 6) Create a program with a function named rollDice that will roll a dice as many times as the user asks and with a user specified number of sides. The function should return the roll of the die. The program should continue while the user presses Y. Sample output: How many times do you want to roll the die? 5 How many sides does the die have: 6 You rolled 1 You rolled 2 You rolled...
. 9. 10. 1. 11. 12. 13. 1. 14. 15. 16 2.1.3.4.1.5. 16. 17:18 Write a int method rolID20(int int m, Randomr) that returns how many times It takes to roll two numbers with a single 20 sided dice. The parameters to the method are as follows: into The first number you are trying to roll int m The second number you are trying to roll Randomr A Random object to simulate the dice rolls. Please see the documentation for...
2. (25 points) Sekora International Casino (SIC) is launching a new game making use of fair 6-sided dice . In phase 1, roll two 6-sided dice and compute the difference between the rolls. Call this difference . In phase 2, roll r dice, and add up the total of the rolls. This is the payout in dollars of the game. (with the numbers 1-6 on the sides). The game proceeds in two phases as follows: (a) (5 points) In the...
Write a script that prints a randomly generated integer between 1 and 6. When I run your script, it should print out only the number that would appear on the die like this: 5 and nothing else. Write a script that takes input for the number of sides on the die. An n sided die should return a random integer between 1 and n with the same stipulations as in Exercise 1. You should take n from the user as...