Menu
Question Index
...


Write a program to print the honeycomb as per the cells given. Empty cells are marked with '*'.

char[][] Printed Output
{{'A', 'B'}, {'C', 'D'}, {'*', 'F'}}   0-0     0-0
 /   \   /   \
0  A  0-0  B  0-0
 \   /   \   /   \
  0-0  C  0-0  D  0
     \   /   \   /
      0-0  F  0-0
         \   /
          0-0
{{'A', 'B', 'C', 'D', 'E', 'F'}}   0-0     0-0     0-0     0-0     0-0     0-0
 /   \   /   \   /   \   /   \   /   \   /   \
0  A  0-0  B  0-0  C  0-0  D  0-0  E  0-0  F  0
 \   /   \   /   \   /   \   /   \   /   \   /
  0-0     0-0     0-0     0-0     0-0     0-0
{{'A'}, {'B'}, {'C'}, {'D'}, {'E'}, {'F'}}   0-0
 /   \
0  A  0-0
 \   /   \
  0-0  B  0
 /   \   /
0  C  0-0
 \   /   \
  0-0  D  0
 /   \   /
0  E  0-0
 \   /   \
  0-0  F  0
     \   /
      0-0
{{'A'}, {'*'}, {'B'}, {'*'}, {'C'}, {'*'}, {'D'}}   0-0
 /   \
0  A  0
 \   /
  0-0
 /   \
0  B  0
 \   /
  0-0
 /   \
0  C  0
 \   /
  0-0
 /   \
0  D  0
 \   /
  0-0
{{'A', 'B', 'C'}, {'D', 'E', 'F'}}   0-0     0-0     0-0
 /   \   /   \   /   \
0  A  0-0  B  0-0  C  0-0
 \   /   \   /   \   /   \
  0-0  D  0-0  E  0-0  F  0
     \   /   \   /   \   /
      0-0     0-0     0-0
{{'A', 'B'}, {'C', 'D'}, {'E', 'F'}}   0-0     0-0
 /   \   /   \
0  A  0-0  B  0-0
 \   /   \   /   \
  0-0  C  0-0  D  0
 /   \   /   \   /
0  E  0-0  F  0-0
 \   /   \   /
  0-0     0-0

class PrintHoneyComb

{    public static void main(String s[])
    {
        char[][] cells = {{'A', 'B'}, {'C', 'D'}, {'*', 'F'}};
        printHoneyComb(cells);

    }


public static void printHoneyComb(char[][] cells) {
//Write code here to print the honeycomb as per the given cells
}

//If required write any additional methods here.
}

Doubts

Problems

Topic: java.util.Arrays - Class Arrays In Collection Framework

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App