Skip to content
Advertisement

Pattern generation in Java

I am trying to make a digital clock pattern using Java. However, I am having trouble printing the ‘digital’ values side-by-side, instead of one after the other. If I print each digit individually, they are rendered correctly, however, printing a specific time with 4 digits is not output correctly. I have tried to use looping to print the digital time, but could not get it to work. Therefore, I made each digit individually so I could print them side-by-side. Any help would be appreciated. Thank you.


Problem Statement:

Take time as input and output a multiline string representing the input, each digit made up of a 5 x 5 grid with a single space between each digit.

The separator is represented as a colon “:”, in its own 5 x 5 grid.

Example #1:

Input:

72:34

Output:

JavaScript

Example #2:

Input:

56:78

Output:

JavaScript

My Solution:

JavaScript

Output:

JavaScript

Advertisement

Answer

Try this.

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement