Skip to content

Commit 723b5f1

Browse files
authored
Create HorizontalChart.java
1 parent 507d29e commit 723b5f1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

HorizontalChart.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.zetcode;
2+
3+
public class HorizontalChart {
4+
5+
public static void main(String[] args) {
6+
7+
int[] nums = {7, 9, 2, 6, 12, 10};
8+
9+
String unit = "*";
10+
11+
for (var num: nums) {
12+
13+
for (int i = 0; i < num; i++) {
14+
15+
System.out.print("*");
16+
}
17+
System.out.println();
18+
}
19+
20+
for (var num: nums) {
21+
22+
System.out.println(unit.repeat(num));
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)