Question: Method Statements in JAVA. I need help on changing my code and implementing method statements in the code as shown in the picture under rules

Method Statements in JAVA. I need help on changing my code and implementing method statements in the code as shown in the picture under rules and requirements. The code below is complete it just needs to be adjusted. I also included the instructions for the completed code that shows what was done. Help will be appreciated.

Method Statements in JAVA. I need help on changing my code and

implementing method statements in the code as shown in the picture under

import java.util.Scanner;

public class Program { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); // display the welcome / instructions System.out.println(); System.out.println(); System.out.println(" Welcome to opponent Dice"); System.out.println("---------------------------------------------------------"); System.out.println("You will be playing dice against the opponent"); System.out.println(); System.out.println("High beats low, and same ties"); System.out.println("Triples beat Straights, Pairs and Junk"); System.out.println("Straights beat Pairs and Junk"); System.out.println("Pairs beat Junk"); System.out.println("In the case of two identical Pairs - high card decides"); System.out.println("in the case of two Nothings - its a tie"); System.out.println("---------------------------------------------------------"); System.out.println(); System.out.println(); String vals = "2357"; // the two Player die int pd1; int pd2; int pd3; // the two opponent die int od1; int od2; int od3; // keep track of results int wins = 0; int loses = 0; int ties = 0; // play again response String pa; do { // roll the Player's dice pd1 = vals.charAt( (int)(Math.random() * 4) ) - '0'; pd2 = vals.charAt( (int)(Math.random() * 4) ) - '0'; pd3 = vals.charAt( (int)(Math.random() * 4) ) - '0';

// display the Player's dice roll System.out.println(" Player"); System.out.println("------------"); System.out.print(" " + pd1 + " " + pd2 + " " + pd3); System.out.print(" ");

// roll the Opponent's dice od1 = vals.charAt( (int)(Math.random() * 4) ) - '0'; od2 = vals.charAt( (int)(Math.random() * 4) ) - '0'; od3 = vals.charAt( (int)(Math.random() * 4) ) - '0'; // display the Opponent's dice roll System.out.println(" opponent"); System.out.println("------------"); System.out.print(" " + od1 + " " + od2 + " " + od3); System.out.print(" "); // analyze the Player's dice roll int playerR = pd1 * pd2 * pd3; int playerP = 0; boolean playerTriple = false; boolean playerStraight = false; boolean playerPair = false; if ( (pd1 == pd2) && (pd2 == pd3) ) playerTriple = true; else if ( (playerR % (2*3*5) == 0) || (playerR % (3*5*7) == 0) ) playerStraight = true; else if ( !((playerR % (2*3*7) == 0) || (playerR % (2*5*7) == 0)) ) { playerPair = true; if ( (pd1 == pd2) ) playerP = pd1; else playerP = pd3; } // analyze the Opponent's dice roll int opponentR = od1 * od2 * od3; int opponentP = 0; boolean opponentTriple = false; boolean opponentStraight = false; boolean opponentPair = false; if ( (od1 == od2) && (od2 == od3) ) opponentTriple = true; else if ( (opponentR % (2*3*5) == 0) || (opponentR % (3*5*7) == 0) ) opponentStraight = true; else if ( !((opponentR % (2*3*7) == 0) || (opponentR % (2*5*7) == 0)) ) { opponentPair = true; if ( (od1 == od2) ) opponentP = od1; else opponentP = od3; } // Triples if ( playerTriple && opponentTriple ) { if ( pd1 > od1 ) // Player has high Triple { ++wins; System.out.println("Congrats, you win!"); } else if ( pd1 opponentR ) // Player has high Straight { ++wins; System.out.println("Congrats, you win!"); } else if ( playerR opponentP ) // Player has high Pair { ++wins; System.out.println("Congrats, you win!"); } else if ( playerP opponentR ) // Player has high card { ++wins; System.out.println("Congrats, you win!"); } else if ( playerR

System.out.println(" ");

} while (pa.equalsIgnoreCase("y"));

// display final results / report System.out.println(); System.out.println("Player Dice Results"); System.out.println("---------------------"); System.out.println("You played " + (wins + ties + loses) + " rounds"); System.out.println(); System.out.println("Rounds won\t:" + wins); System.out.println("Rounds tied\t:" + ties); System.out.println("Rounds lost\t:" + loses); System.out.println("---------------------"); System.out.println(); stdIn.close(); } } // class

Rules and Requirements: . All user input must be validated (user validation loop) in a reasonable manner . Given the following method heading, you must write the corresponding definition for a void return method that displays a brief accounting of the rules and format of your game // displays a brief accounting of the rules and format of the game public static void welcome() . Given the following method heading, you must write the corresponding definition for a int return method that generates and returns a random int seleceted from the set [2, 3, 5, 7) // returns a randomly selected int in the set [2, 3, 5, 7 public static int rollDie) . Given the following method heading, you must write the corresponding definition for a boolean return method that returns true if and only if the three dice constitute a three of a kind // returns true only when triple public static boolean isTriple(int di, int d2, int d3) * Given the following method heading, you must write the corresponding definition for a boolean return method that returns true if and only if the three dice constitute a straight // returns true only when straight public static boolean isStraight(int d1, int d2, int d3) . Given the following method heading, you must write the corresponding definition for a boolean return method that returns true if and only if the three dice constitute a pair // returns true only when pair public static boolean isPair(int di, int d2, int d3) . Given the following method heading, you must write the corresponding definition for a int return method that returns +1 if the Player's dice win the round; returns 0 if the Player and Opponent tie ; and returns -1 if the Opponent's dice win the round // returns true only when pair public static int roundOutcome (int pl, int p2, int p3, int o1, int o2, int o3) . Given the following function heading, you must write the corresponding definition for a void return method that generates a reasonable report of a game's outcomes // displays a report of the game's outcomes to the screen public static void report(int wins, int ties, int loses)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!