Answered step by step
Verified Expert Solution
Question
1 Approved Answer
By the end of this lab, you will be able to: Create a Java program that makes decisions using multi-way if statements. Write a method
By the end of this lab, you will be able to: Create a Java program that makes decisions using multi-way if statements. Write a method that accepts data through parameters and returns data to the caller. Use the Random class to generate random integers. Work with variables of the char data type. Task Write a Java program that finds the winner of a randomly completed tic-tac-toe board. Your code will assign each spot on the board randomly with '_', 'O', 'X' and determines if O, X, both, or none wins. Create a project and class named Lab5FirstnameLastname using your actual first and last names in NetBeans to hold your program. Let your variables b11, b12, b13, b21, b22, b23, b31, b32, b33 represent the 3 x 3 tic tac toe board as follows: b11 b12 b13 b21 b22 b23 b31 b32 b33 Write a method named setValue() which doesnt take any parameters but will return one of 3 possible random characters: '_', 'O', 'X' to the caller. Call this method from your main method to assign each of your board variables with '_', 'O', or 'X'. You can use the following code to generate the random characters returned by your setValue() method: String ox = "OX_"; Random rnd = new Random(); int n = rnd.nextInt(3); char c = ox.charAt(n); Write a method named printBoard() which accepts the 9 board variables as parameters and outputs the result of the game to the console. This method MUST use printf to output the game board to the console using the format shown above. The method printBoard() will not return anything to the caller.
NO LOOPS: IF Statements
follow the methods
Step 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