File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package pattern_program ;
2+
3+ /*
4+ Write a program to print letter H exactly as shown below -
5+ $$$$$##$$$$$
6+ ##
7+ ##
8+ ##
9+ ##
10+ ##
11+ ##
12+ ##
13+ ##
14+ ##
15+ $$$$$##$$$$$
16+ */
17+
18+
19+ import java .util .Scanner ;
20+
21+ public class Letter_I {
22+
23+ // main logic
24+ public static void printI (int height )
25+ {
26+ for (int i = 0 ; i < height ; i ++)
27+ {
28+ for (int j = 0 ; j < height ; j ++)
29+ {
30+ if ((i == 0 || i == height - 1 ) && (j != height -j -1 )) {
31+ System .out .printf ("$" );
32+ } else if (j == height / 2 || (i == 0 || i == height - 1 )) {
33+ System .out .printf ("##" );
34+ }
35+ else {
36+ System .out .printf (" " );
37+ }
38+ }
39+ System .out .printf ("\n " );
40+ }
41+ }
42+
43+ public static void main (String [] args ) {
44+
45+ Scanner sc = new Scanner (System .in );
46+
47+ System .out .println ("Please specify the height of the alphabet and keep that integer odd." );
48+
49+ int height = sc .nextInt ();
50+ if (height % 2 == 0 ) {
51+ System .out .println ("Please specify any odd integer for a better view." );
52+ } else {
53+ printI (height );
54+ }
55+
56+ sc .close ();
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments