import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number between 0 and 511: "); int number = input.nextInt(); input.close(); char[] chArray = Integer.toBinaryString(number).toCharArray(); char[][] displayArray = new char[3][3]; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { displayArray[i][j] = chArray[i * 3 + 1]; if(displayArray[i][j] == '0') System.out.print('H' + " "); else System.out.print('T' + " "); } System.out.println(); } } }