Menu
Question Index
...


Given a string, write a program to arrange the string according to the alignments like HL(Horizontal Left), HR(Horizontal Right), VT(Vertical Top), VB(Vertical Bottom). For more information look at the requirements.

Input (String, String) Printed Output
'Sun rises in the east', HL O---O---O---O---O---O
| S | U | N |   |   |
O---O---O---O---O---O
| R | I | S | E | S |
O---O---O---O---O---O
| I | N |   |   |   |
O---O---O---O---O---O
| T | H | E |   |   |
O---O---O---O---O---O
| E | A | S | T |   |
O---O---O---O---O---O
'Sun rises in the east', HR O---O---O---O---O---O
|   |   | S | U | N |
O---O---O---O---O---O
| R | I | S | E | S |
O---O---O---O---O---O
|   |   |   | I | N |
O---O---O---O---O---O
|   |   | T | H | E |
O---O---O---O---O---O
|   | E | A | S | T |
O---O---O---O---O---O
'Sun rises in the east', VT O---O---O---O---O---O
| S | R | I | T | E |
O---O---O---O---O---O
| U | I | N | H | A |
O---O---O---O---O---O
| N | S |   | E | S |
O---O---O---O---O---O
|   | E |   |   | T |
O---O---O---O---O---O
|   | S |   |   |   |
O---O---O---O---O---O
'Sun rises in the east', VB O---O---O---O---O---O
|   | R |   |   |   |
O---O---O---O---O---O
|   | I |   |   | E |
O---O---O---O---O---O
| S | S |   | T | A |
O---O---O---O---O---O
| U | E | I | H | S |
O---O---O---O---O---O
| N | S | N | E | T |
O---O---O---O---O---O
'Pawan is great', VB O---O---O---O
| P |   | G |
O---O---O---O
| A |   | R |
O---O---O---O
| W |   | E |
O---O---O---O
| A | I | A |
O---O---O---O
| N | S | T |
O---O---O---O
'Pawan is great', HR O---O---O---O---O---O
| P | A | W | A | N |
O---O---O---O---O---O
|   |   |   | I | S |
O---O---O---O---O---O
| G | R | E | A | T |
O---O---O---O---O---O

class PrintBanner

{    public static void main(String s[])
    {
        printBanner("Sun rises in the east", "HR");

    }


public static void printBanner(String banner, String align) {
//Write code here to print the formatted string according to the given input
}

//If needed, write any additional methods here
}

Doubts

Problems

Topic: Java Character Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App