Question

In: Computer Science

C# Yahtzee Program I am creating a Yahtzee program where you have the option to choose...

C# Yahtzee Program

I am creating a Yahtzee program where you have the option to choose 5 or more dice that will be rolled. I just need help trying to create a random dice roll and seeding it. Could you give me some code examples of getting a dice roll of a six sided die that won't display similar results.

Solutions

Expert Solution

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

int main()
{ int dice[100],n,i;
while(1){
printf("Enter no of dice(>=5):");
scanf("%d",&n);
if(n>=5)
break;
else
printf("please enter correct no of dice\n");
}
printf("rolling the %d dice resulted:\n",n);
srand(time(0));
for (i = 0; i < n; i++) {
int num = (rand() % 6) +1;
printf("%d ", num);
}

return 0;
}


Related Solutions

I am working on a C++ program, where a user puts in a notation a playing...
I am working on a C++ program, where a user puts in a notation a playing card and the output is the full name of the card.(ex: KH = King of Hearts) I have most of it working but I want to have an error come up when the user puts in the wrong info and then loop back to the original question. Am I setting it up wrong? Pasted below is my code #include<iostream> #include<string> using namespace std; int...
I am trying to solve a c++ problem over c strings where I have to input...
I am trying to solve a c++ problem over c strings where I have to input an email address and check if it is valid. After completing my code I keep getting errors that my program will not run, specifically the lines with my for loops. Can you please look at my code and tell me what is wrong and how I can fix the code? I included below the assignment instructions and my current code. Assignment Instructions Write a...
I am creating a system for a security design and need to choose controls for network...
I am creating a system for a security design and need to choose controls for network security and those with access controls as well. I need to decide what major network security controls I would need to recommend. Which ones are good examples and why? Within that, I need to describe three access control techs. and their essentials for util. apps. Are there a few cases to assist in demonstrating those access control techs.
I am creating a program in Python that allows the user to input a credit card...
I am creating a program in Python that allows the user to input a credit card number, and determine if the card is valid. This should be done by taking every other number, starting from the right, and adding them together. The doubling each of the other digits, and adding them together as single digits, and then adding the two sums together. For example, if the number 4833 1200 3412 3456 is used, the first sum should be 6+4+2+4+0+2+3+8=29, the...
I am writing a shell program in C++, to run this program I would run it...
I am writing a shell program in C++, to run this program I would run it in terminal like the following: ./a.out "command1" "command2" using the execv function how to execute command 1 and 2 if they are stored in argv[1] and argv[2] of the main function?
This program needs to be in C++. I have barely gotten anywhere but am already stuck....
This program needs to be in C++. I have barely gotten anywhere but am already stuck. Any help with this one would be greatly appreciated. Write a program that simulates playing a simplified version of the game "Candy Land." In "Candy Land" players take turns drawing cards that have a colored square on them. The player then travels on the board according to the color on the card. The first person to reach the end of the board wins. In...
I am trying to create a makefile for the following program in Unix. The C++ program...
I am trying to create a makefile for the following program in Unix. The C++ program I am trying to run is presented here. I was wondering if you could help me create a makefile for the following C++ file in Unix and show screenshots of the process? I am doing this all in blue on putty and not in Ubuntu, so i don't have the luxury of viewing the files on my computer, or I don't know how to...
Hello this is for C++ language. I am currently stuck on creating my api for Day...
Hello this is for C++ language. I am currently stuck on creating my api for Day Trading Stocks. as follows I need an api for *//Function Signature * * parameter: * * Return Value: ** *// Write the following function taking in an integer vector (vector &prices) consisting of all prices, in chronological order, for an hypothetical instrument. Your function recommends the maximum profit an investor can make by placing AT MOST one buy and one sell order in the...
I am currently working on creating a dice game. I have not figured out how to...
I am currently working on creating a dice game. I have not figured out how to make it work? What should I do to make it work? Here is what I have so far: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Dice Game</title> <link rel="stylesheet" type="text/css" href="dice.css"> </head> <body> <div class="row" align="center"> <div class="col-4"> <h3>Your Dice</h3> <img src="dice images/m1.png" width="100" height="100" alt="roll: 1" id="mydice1"/> <img src="dice images/m1.png" width="100" height="100" alt="roll: 1" id="mydice2"/> </div> <div class="col-4"> <h3>Opponent's Dice</h3> <img src="dice images/o1.png" width="100"...
I am creating a crop watering "simulator" in Python. I have the user input an array...
I am creating a crop watering "simulator" in Python. I have the user input an array and then must compare the placement of water and crops to determine if all the crops in the array are watered. The user will either input a "w" for water or "c" for crop when creating the array. A w cell can water 8 cells around it, including itself. My end result must determine if all the crops will be watered or not. How...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT