Nine coins are placed in a 3x3 matrix with some face up and some face down. You can represent the state of the coins using a 3x3 matrix with values 0 (heads) and 1 (tails). Here are some examples:...


Nine coins are placed in a 3x3 matrix with some face up and some face down. You can represent the state of the coins using a 3x3 matrix with values 0 (heads) and 1 (tails). Here are some examples:


0 0 0 1 0 1 1 1 0
0 1 0 0 0 1 1 0 0
0 0 0 1 0 0 0 0 1


Each state can also be represented using a binary number. For example, the preceding matrices correspond to the numbers:


000010000 101001100 110100001


There are a total of 512 possibilities, so you can use decimal numbers 0, 1, 2, 3,...,511 to represent all the states of the matrix.


Write a program that prompts the user to enter a number between 0 and 511 and displays the corresponding matrix with the characters H and T.


Nine coins are placed in a 3x3 matrix with some face up and some face down. You can represent the state of the coins using a 3x3 matrix with<br>values 0 (heads) and 1 (tails). Here are some examples:<br>00 0 1 0 1 1 10<br>0 10 0 0 1 100<br>00010000 1<br>Each state can also be represented using a binary number. For example, the preceding matrices correspond to the numbers:<br>000010000 101001100 110100001<br>There are a total of 512 possibilities, so you can use decimal numbers 0, 1, 2, 3.,511 to represent all the states of the matrix.<br>Write a program that prompts the user to enter a number between 0 and 511 and displays the corresponding matrix with the characters H and T.<br>SAMPLE RUN #1: java HeadsAndTails<br>Standard Output<br>Hide Invisibles<br>Enter.an integer representing.the.state.of.the.coins:H.T.T<br>T T.T<br>

Extracted text: Nine coins are placed in a 3x3 matrix with some face up and some face down. You can represent the state of the coins using a 3x3 matrix with values 0 (heads) and 1 (tails). Here are some examples: 00 0 1 0 1 1 10 0 10 0 0 1 100 00010000 1 Each state can also be represented using a binary number. For example, the preceding matrices correspond to the numbers: 000010000 101001100 110100001 There are a total of 512 possibilities, so you can use decimal numbers 0, 1, 2, 3.,511 to represent all the states of the matrix. Write a program that prompts the user to enter a number between 0 and 511 and displays the corresponding matrix with the characters H and T. SAMPLE RUN #1: java HeadsAndTails Standard Output Hide Invisibles Enter.an integer representing.the.state.of.the.coins:H.T.T T T.T

Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here