Please help! I have to write a program for the game Bunco! I need help for it randomly re-rolling the dice each round- right now it is staying the same.
The concept is for Round 1- if they rolled a 1 and a 2 and a 3- their score would be 1 because they only rolled one 1 in that round.
I also need help with the sum of all rounds!
Bunco.java
//copy the code and run it
//NOTE: comments are in between the code
//If have any problem then feel free to ask in the comment
section
import java.util.Random;
public class Bunco{
public static void main(String[] args){
int roll1,roll2,roll3;
int round = 1;
int score = 0;
int sum = 0;
System.out.print("Welcome to the
Bunco Game\n");
Random die = new Random();
do{
//dice is rolled
for each iteration separately
//previously in
your code it is rolled only once
//that's why it
shows same each time
roll1 =
die.nextInt(6) + 1;
roll3 =
die.nextInt(6) + 1;
roll2 =
die.nextInt(6) + 1;
System.out.print("Round "+round+"\n");
System.out.print("You rolled a "+roll1+" and a "+roll2+" and a
"+roll3+"\n");
score = 0;
//here only
one condition needs to be true in order to get the score
calculated
if (roll1==round
&& roll2==round && roll3==round){
System.out.print("BUNCO! \n");
score = 21;
}
else
if(roll1==roll2 && roll2==roll3 &&
roll3==roll1){
System.out.print("MINI BUNCO! \n");
score = 5;
}
else
if(roll1!=round && roll2!=round &&
roll3!=round)
score = 0;
else
{
if(roll1==round)
score++;
if(roll2==round)
score++;
if(roll3==round)
score++;
}
//score is
printed after calculation of score from above
System.out.print("You score for round "+round+" is
"+score+"\n");
//sum stores the
score for each round so it is calculted inside the loop
sum +=
score;
// round
number is incremented at the end of one iteration
round++;
}while(round<=6);
System.out.print("Score for all
rounds is "+sum);
}
}
code image is:
output image is:
If have any doubt feel free to ask in the comment section.
Please help! I have to write a program for the game Bunco! I need help for...
JAVA HELP: Directions Write a program that will create an array of random numbers and output the values. Then output the values in the array backwards. Here is my code, I am having a problem with the second method. import java.util.Scanner; import java.util.Random; public class ArrayBackwards { public static void main(String[] args) { genrate(); print(); } public static void generate() { Scanner scanner = new Scanner(System.in); System.out.println("Seed:"); int seed = scanner.nextInt(); System.out.println("Length"); int length = scanner.nextInt(); Random random...
need help editing or rewriting java code, I have this program running that creates random numbers and finds min, max, median ect. from a group of numbers,array. I need to use a data class and a constructor to run the code instead of how I have it written right now. this is an example of what i'm being asked for. This is my code: import java.util.Random; import java.util.Scanner; public class RandomArray { // method to find the minimum number in...
I am currently doing homework for my java class and i am getting an error in my code. import java.util.Scanner; import java.util.Random; public class contact { public static void main(String[] args) { Random Rand = new Random(); Scanner sc = new Scanner(System.in); System.out.println("welcome to the contact application"); System.out.println(); int die1; int die2; int Total; String choice = "y";...
Please Help! I need to update the code below to meet these criteria! 1. The constructor of die class initializes face of Die to 3 2. roll method updates face of die to value from 1-6 3. getFace() method provides current face to the main program 4. main create a Die object 5. main create a Die object 6. main rolls die 5 times 7. main computes sum of rolls 8. main computes actual average of the rolls <--------- Code...
Look for some finshing touches java help with this program. I just two more things added to this code. A loop at the end that will ask the user if they want to quit if they do want to quit the program stops if they don't it loads a new number sequence. import java.util.Random; import java.util.ArrayList; import java.util.Scanner; import java.util.Arrays; import java.util.List; import java.util.Collections; public class main { public static void main(String[] args) { List < Sequence > list =...
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...
Goal: Translate this Python script into Java: magic8ball.py Deliverable: Magic8Ball.java Grading Breakdown: Functionality: 35; Source code comments: 5; Indentation: 5; Properly Submitted: 5. Example: Here is a Java class that simulates the roll of a single die: import java.util.Random; public class DiceRoll { public static void main(String[ ] args) { Random r = new Random( ); int roll1 = r.nextInt(6) + 1; int roll2 = r.nextInt(6) + 1; System.out.println("Sum of rolls:" + (roll1 + roll2)); } } Here is the...
Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public class Project2 { //Creating an random class object static Random r = new Random(); public static void main(String[] args) { char compAns,userAns,ans; int cntUser=0,cntComp=0; /* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in); System.out.println("*************************************"); System.out.println("Prime Number Guessing Game"); System.out.println("Y = Yes , N = No...
I need help on creating a while loop for my Java assignment. I am tasked to create a guessing game with numbers 1-10. I am stuck on creating a code where in I have to ask the user if they want to play again. This is the code I have: package journal3c; import java.util.Scanner; import java.util.Random; public class Journal3C { public static void main(String[] args) { Scanner in = new Scanner(System.in); Random rnd = new Random(); System.out.println("Guess a number between...
I need to write a program in java that reads a text file with a list of numbers and sorts them from least to greatest. This is the starter file. import java.util.*; import java.io.*; public class Lab3 { static final int INITIAL_CAPACITY = 5; public static void main( String args[] ) throws Exception { // ALWAYS TEST FOR REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println("\nusage: C:\\> java Lab3 L3input.txt\n"); System.exit(0); } //...