Question: 1.1 A printTable method (with a parameter character ) that prints numbers from 0 to 256 in 3 different formats. The print out should be
1.1 A printTable method (with a parameter character ) that prints numbers from 0 to 256 in 3 different formats. The print out should be 16 numbers/characters per line.
1. If the parameter is d, print out the number in decimal format (" %3d ") 2. If the parameter is h, print out the number in hexadecimal format (" %3x ") 3. If the parameter is c, print out the number in character format (" %3c ")
1.2 You can use the following code as your main method.
public static void main(String args[]) {
// print out ASCII table ( 8 bits, 0-256 )
//print a linefeed every 16 characters
//1. 1st table in decimal format
System.out.printf( " ---- Decimal ----" ); printTable('d' );
// 2. 2nd table in hexadecimal format
System.out.printf( " ---- HexaDecimal ----" ); printTable('h' );
// 3. 3nd table, ASCII table
System.out.printf( " ---- ASCII ----" ); printTable('c' ); }
Should look something like this... just evenly spaced
---- Decimal ----
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
:
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
---- Hexadecimal ----
0 1 2 3 4 5 6 7 8 9 a b c d e f
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
:
f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
---- ASCII table ----
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
:
@ A B C D E F G H I J K L M N O
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
