I'm writing a program in game for a dice game. During the game you decide if you want to roll or pass to the next player, mine so far will just keep rolling until you roll the same number again (besides six) and then move to the next player. How do I get it to manually change players by the player response "y" or "n"?
This is what I have for this part of the game simulator and it doesn't work
System.out.println("Do you want to roll again? y or n");
boolean
roll;
// Check if
Player wants to roll again
Answer =
kbd.nextLine().trim().toLowerCase();
if
(Answer.equals("y")) {
roll = true;
break;
} else if (Answer.equals("n")) {
roll = false;
break;
} else {
System.out.println("Please answer either y or
n");
} // end "for ()"
input = kbd.nextLine();
Screenshot
---------------------------------------------------------------------
Program
import java.util.Scanner;
public class DiceRoll {
public static void main(String[] args) {
//Scanner object for input
read
Scanner kbd=new
Scanner(System.in);
//Variable for check
boolean roll=true;
//Loop until enter 'n'
while(roll==true) {
//Loop
repeatation deciding question
System.out.println("Do you want to roll again? y or n");
char
answer=Character.toLowerCase(kbd.nextLine().charAt(0));
//If yes
repeat
if(answer=='y')
{
roll=true;
}
//Otherwise
break;
else
if(answer=='n') {
roll=false;
}
else {
System.out.println("Please answer either y or
n");
}
}
}
}
----------------------------------------------------------------------
Output
Do you want to roll again? y or n
y
Do you want to roll again? y or n
k
Please answer either y or n
Do you want to roll again? y or n
n
-------------------------------------------------------
Note
I assume you want this kind of loop.
If you give full details of the program, i can understand what kind of loop are expecting
I'm writing a program in game for a dice game. During the game you decide if...
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...
python code( using functions please)! Rules of the game: - This game requires a dice. The goal of the game is to collect the correct number of coins to create a dollar. Players take coins based on a roll of the dice. The numbers on the dice correlate to the coin values as follows: 1—penny 2—nickel 3—dime 4—quarter 5— ( pick a random card from 1 to 4): o 1 = penny o 2 =...
can someone help me fix my jeopardy dice game I am having a hard time figuring out what i am doing wrong #include #include using namespace std; //this function makes a number between 1 and 6 come out just like a dice int rollDie() { return (rand() % 6+1); } //this function asks the user with a printed statement if they want to roll the dice and gives instructions for yes and no (y/n) void askYoNs(){ cout<<"Do you want to...
The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a six-sided die: If the player rolls a 1, then the player gets no new points and it becomes the other player’s turn. If the player rolls 2 through 6, then he or she can either ROLL AGAIN or HOLD: At this point, the sum of all rolls...
9. In the casino dice game Craps, players make wagers on a sequence of rolls of a pair of dice. A sequence of rolls starts with the "shooter" making an initial roll of two dice called the "come-out” roll. If the sum of the dice on the initial roll is 7 or 11 then a player with a bet on the Pass Line wins. If the initial roll results in a sum of 2, 3, or 12 ("craps") then a...
java
thank you!
Pig is a traditional dice jeopardy game. Players take turns, starting with a randomly-chosen player. On their turn a player rolls a single 6-sided die 1 or more times. After each roll, the player has a choice: hold Stop rolling and add the total of al numbers rolled this turn to their score, or roll Roll the die again. If the player rolls a 1, their turn ends and they score 0 for the turn. Points scored...
Two player Dice game In C++ The game of ancient game of horse, not the basketball version, is a two player game in which the first player to reach a score of 100 wins. Players take alternating turns. On each player’s turn he/she rolls a six-sided dice. After each roll: a. If the player rolls a 3-6 then he/she can either Roll again or Hold. If the player holds then the player gets all of the points summed up during...
Use C++ 11 to write the program War Game Requirement Setting This is a 2-player game. It is played through dice. Rule for scoring The player who rolls higher number gets one point. If both players roll the same number, it is considered a draw and no one gets a point. Dice Specification There are two kinds of dice: normal die, represented by Die class. loaded die, represented by the loadedDie class. Classes Die class Die class has a member...
Problem Statement: A company intends to offer various versions of roulette game and it wants you to develop a customized object-oriented software solution. This company plans to offer one version 100A now (similar to the simple version in project 2 so refer to it for basic requirements, but it allows multiple players and multiple games) and it is planning to add several more versions in the future. Each game has a minimum and maximum bet and it shall be able...
WITHOUT FUNCTIONS. Could anyone help me solve this problem not using the function ? Thanks a lot. Pig Dice Game Pig is a simple two player dice game, played with one die. The first player to reach or surpass 50 is the winner. Each player takes a turn rolling the dice. They add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. The risk being they could lose the amount...