PDA

View Full Version : Hi everyone . I am trying to solve a java program


sherry11111
Mar 18, 2016, 05:20 AM
48264

Can I print this in java using loops ? THANKS

CravenMorhead
Mar 18, 2016, 07:13 AM
Yes.

create a 2d array that contains a mapping for each character and it's position.
i.e. 1=b, 2=o, 0=' '.
[1 2 2 0 0]
[1 2 2 1 0]

Then loop through each line and each character and, using a switch statement, print out the character:
for(I=0 to lastLine){
for(j=0 to lastChar){

switch(map[i][j]){

case 1:print('b');
case 2:print('o');
case 0:print(' ');
default:
}
}
print ('\n');
}

The is the pusedo code, the rest is up to you.