I'm trying to make a game of Craps in C++. This is how the teacher wants the program to run.
Player rolled: 6 + 4 = 10 The point is 10 Player rolled: 3 + 3 = 6 Player rolled: 6 + 3 = 9 Player rolled: 3 + 1 = 4 Player rolled: 3 + 4 = 7 You seven'd out and lost!
Player rolled: 2 + 5 = 7 You won!
Player rolled: 3 + 1 = 4 The point is 4 Player rolled: 5 + 1 = 6 Player rolled: 4 + 4 = 8 Player rolled: 6 + 6 = 12 Player rolled: 4 + 4 = 8 Player rolled: 2 + 1 = 3 Player rolled: 5 + 1 = 6 Player rolled: 2 + 4 = 6 Player rolled: 3 + 5 = 8 Player rolled: 5 + 3 = 8 Player rolled: 2 + 1 = 3 Player rolled: 2 + 2 = 4 You rolled your point! You won!
Player rolled: 6 + 6 = 12 Craps! You lost!
This is what I got so far
#include <iostream>
#include <ctime>
#include <time.h>
#include <cstdlib>
using namespace std;
int main()
{
int die1;
int die2;
int rollingDice;
int rollingDice2;
const int SnakeEyes = 1 + 1;
const int Boxcars = 6 + 6;
const int Craps = 2 or 3 or 12;
srand(21);
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1;
rollingDice = die1 + die2;
rollingDice2 = die1 + die2;
cout << "Player rolled: " << die1 << " + "
<< die2 << " = " << rollingDice << endl
<< endl;
if (rollingDice == 7 or rollingDice ==
11)
{
cout << "You won!" << endl;
}
else if (rollingDice == 2 or rollingDice == 3
or rollingDice == 12)
{
cout << "Craps! You lost!" << endl;
}
else if ( rollingDice == 4 or rollingDice == 5 or rollingDice == 6 or rollingDice == 8 or rollingDice == 9 or rollingDice == 10)
{
cout << "The Point is " << rollingDice << endl
<< endl;
}
while (rollingDice2 != rollingDice && rollingDice2 != 7);
if (rollingDice2 == rollingDice)
{
cout << "You rolled your point! You won!" <<
endl;
}
else if (rollingDice2 != 7)
{
cout << "You
seven'd out and lost!" << endl;
}
else if (rollingDice2 = )
}
If you have any doubts, please give me comment...
#include <iostream>
#include <ctime>
#include <time.h>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int die1;
int die2;
int rollingDice;
int rollingDice2;
const int SnakeEyes = 1 + 1;
const int Boxcars = 6 + 6;
const int Craps = 2 or 3 or 12;
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1;
rollingDice = die1 + die2;
cout << "Player rolled: " << die1 << " + " << die2 << " = " << rollingDice << endl
<< endl;
if (rollingDice == 7 or rollingDice == 11)
{
cout << "You won!" << endl;
}
else if (rollingDice == 2 or rollingDice == 3 or rollingDice == 12)
{
cout << "Craps! You lost!" << endl;
}
else
{
cout << "The Point is " << rollingDice << endl
<< endl;
while (1)
{
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1;
rollingDice2 = die1 + die2;
cout << "Player rolled: " << die1 << " + " << die2 << " = " << rollingDice2 << endl;
if (rollingDice2 == rollingDice)
{
cout << "You rolled your point! You won!" << endl;
break;
}
else if (rollingDice2 == 7)
{
cout << "You seven'd out and lost!" << endl;
break;
}
}
}
}
I'm trying to make a game of Craps in C++. This is how the teacher wants...
This is for C++ #include <random> #include <iostream> #include <ctime> using namespace std; /* In the game of craps, a shooter rolls 2 dice and adds the dots on the upper most faces of the dice. 7 or 11 on the first roll wins, 2, 3, or 12 on the first roll loses, andthing else is call the point and the player rolls again The following program fragment uses 1-way if statements simulate the 1st roll of the dice. Replace...
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
Required in C++ I'm asked to: Print a histogram in which the total number of times the dice rolls equals each possible value is displayed by printing a character like * that number of times. Below is my current code. I am not allowed to use arrays or anything too advanced as I just started the class. I would really appreciate the help as I've been stuck on it for a while now. I can only get it to print...
can someone help me fix my jeopardy game #include<iostream> #include<stdlib.h> using namespace std; int rollDie() { return (rand() % 6+1); } void askYoNs(){ cout<<"Do you want to roll a dice (Y/N)?:"<<endl; } void printScores(int turnTotal,int humanTotal,int compTotal){ int player; int human; if(player==human){ cout<<"Your turn total is "<<turnTotal<<endl; } else{ cout<<"computer turn total is "<<turnTotal<<endl; } cout<<"computer: "<<compTotal<<endl; cout<<"human: "<<humanTotal<<endl; cout<<endl; } int human; int changePlayer(int player){ if(player==human) return 1; return human; } int process(int& turnTotal,int roll,int curr_player,int& humanTotal,int& computerTotal){ if(roll==2...
Game of Craps C++ #include <iostream> using namespace std; void roll (int *); // using pointer to catch the random variable value of two dicerolls at one time . //these global variable with static variable win use to operate the working of code . //static win, account because two times input given by user to add the diceroll with win number and //account (means balance of user) . static int account = 100; static int win = 0; int bet...
C# Code: Write the code that simulates the gambling game of craps. To play the game, a player rolls a pair of dice (2 die). After the dice come to rest, the sum of the faces of the 2 die is calculated. If the sum is 7 or 11 on the first throw, the player wins and the game is over. If the sum is 2, 3, or 12 on the first throw, the player loses and the game is...
The Code is C++ // tic tac toe game #include <iostream> using namespace std; const int SIZE = 9; int check(char *); void displayBoard(char *); void initBoard(char *); int main() { char board[SIZE]; int player, choice, win, count; char mark; count = 0; // number of boxes marked till now initBoard(board); // start the game player = 1; // default player mark = 'X'; // default mark do { displayBoard(board); cout << "Player " << player << "(" << mark...
Hello, I am working on my final and I am stuck right near the end of the the program. I am making a Tic-Tac-Toe game and I can't seem to figure out how to make the program ask if you would like to play again, and keep the same names for the players that just played, keep track of the player that wins, and display the number of wins said player has, after accepting to keep playing. I am wanting...
i have created a program for a game of rock, paper, scissors but i must make it run more than once in some kind of loop. i want to add a function named runGame that will control the flow of a single game. The main function will be used to determine which game mode to initiate or exit program in Player vs. Computer, the user will be asked to enter their name and specify the number of rounds for this...
Hello, I am working on a C++ pick 5 lottery game that gives you the option to play over and over. I have everything working right except that every time the game runs it generates the same winning numbers. I know this is an srand or rand problem, (at least I think it is), but I can't figure out what my mistake is. I've tried moving srand out of the loop, but I'm still getting the same random numbers every...