Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Hi everyone . I am trying to solve a java program (https://www.askmehelpdesk.com/showthread.php?t=822959)

  • Mar 18, 2016, 05:20 AM
    sherry11111
    1 Attachment(s)
    Hi everyone . I am trying to solve a java program
    Attachment 48264

    Can I print this in java using loops ? THANKS
  • Mar 18, 2016, 07:13 AM
    CravenMorhead
    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.

  • All times are GMT -7. The time now is 11:58 PM.