-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp9.java
More file actions
26 lines (24 loc) · 824 Bytes
/
p9.java
File metadata and controls
26 lines (24 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* Write an interactive program to print a string entrered in a pyramid form. For instance, the string
“stream” has to be displayed as follows
s
s t
s t r
s t r e
s t r e a
s t r e a m
*/
public class p9 {
public static void main(String args[]) {
String str = "stream";
int len = str.length();
for(int i = 0; i < len; i++) {
int space = len - i;
for(int j = 0; j < space; j++)
System.out.print(" ");
for(int k = 0; k <= i; k++)
System.out.print(str.charAt(k) + " ");
System.out.println("");
}
}
}