Question
I need help with question 12B I don't know how to write it. I already wrote thanks to everyon help for 12A; HERE IS MY
I need help with question 12B I don't know how to write it.
I already wrote thanks to everyon help for 12A;
HERE IS MY 12A
import java.util.Scanner; import java.util.Random; public class Pig5 { public static void main(final String[] args) { int turn=0; int score=0; int overall1 =0; int overall2 =0; /* Continue as long as both player's score is =50){ System.out.println(" Player1 wins and her score = "+overall1); }else{ System.out.println(" Player2 wins and her score = "+overall2); } }
public static int playOneTurn() { String name="Player2";; int overallScore=0; Random pseudoRandomGenerator = new Random(); int roundScore=0; int currScore = pseudoRandomGenerator.nextInt(6)+1; System.out.print(" "+name+" rolls "+currScore); if(currScore == 1){ System.out.print(" Turn over. Round Score = 0"); return roundScore; }else{ roundScore = currScore; boolean continueRound = true; Scanner sc = new Scanner(System.in); while(continueRound==true){ System.out.print(" Do you want to roll again(Y/N)?"); if(sc.next().equals("Y")){ currScore = pseudoRandomGenerator.nextInt(6)+1; System.out.print("Choses to roll again. Rolls a "+currScore); if(currScore == 1){ System.out.print(" Turn over. Round Score = 0"); return 0; }else{ roundScore += currScore; } }else{ System.out.print("Choses to stop. Round Score = "+roundScore); continueRound = false; } } } return roundScore; } /* * Method for one turn of the computer player */ public static int playOneComputerRound(){ int roundScore=0; String name="Player2"; int overallScore=0; Random pseudoRandomGenerator = new Random(); //Get the first score of the round int currScore = pseudoRandomGenerator.nextInt(6)+1; System.out.print(" "+name+" rolls "+currScore); //Return score 0 if the first score = 1 if(currScore == 1){ System.out.print(" Turn over. Round Score = 0"); return roundScore; }else{ roundScore = currScore; //Chose to roll if the roll of 100 dice is >= 3 times the round score. while(pseudoRandomGenerator.nextInt(101)>=3*roundScore){ currScore = pseudoRandomGenerator.nextInt(6)+1; System.out.print(" Choses to roll again. Rolls a "+currScore); //Return score 0 if it gets a score = 1, otherwise add the current score to the round score. if(currScore == 1){ System.out.print(" Turn over. Round Score = 0"); return 0; }else{ roundScore += currScore; } } } System.out.print(" Round Score = "+roundScore); return roundScore; } }
Show transcribed image text
G The Dice game "Pig'is x U Pig Game (Beginning omat https://egator.greenriver.edu/courses/1560450/assignments/1 1912257#submit 58141-2683-COMPUTER SCIENCE I JAVA > Assignments > A Programming Assignm A Programming Assignm 1G Attached To This Assg Programming Assignment 128 018 Programming Assignment 12B bus Due Tuesday by 9:59pm Points 5 Submitting a file upload ules This program is a modification of the previous assignment (12A). In this program you are going to replace one of the human players with a computer controlled player. ades es ages You will take your old code for Assignment #12A and remove player two and replace it with code for a computer controlled player 2. You will need to write a new playOneComputerRound0 method for the computer player The computer player plays with the exact same rules as the human player, but its behavior is controlled by the following rules. . When given the choice to roll or to stop, the computer will take the current round score times three percent. It will then roll a 100 sided dice and compare it to that percentage.If the die is less than the percent, it will stop. . If it rolls a one, it stops just like the human does. It doesn't get a choice. For example, if the first roll is a 5, then it has a 15% chance of stopping and an 85% chance of going again. If it goes again, and the second roll is a 2, it now has a 21% chance of stopping as the round scores at 7 and 7.3-21%. . The computer doesn't care about the overall score or the human's score, only the current round score. The game should continue to 50 as before, and the program should then calculate a winner File Upload Google Doc Upload a file, or choose a file you've already uploaded tep KhStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started