forked from projects-manager/IC2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHellos.java
More file actions
31 lines (17 loc) · 683 Bytes
/
Hellos.java
File metadata and controls
31 lines (17 loc) · 683 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
public class Hellos {
public static void main(String[] args) {
int n = Integer.parseInt(args[0]);
int i = 1;
while (i<=n) {
if (i%100 >= 11 && i%100 <=20) {
System.out.println(i+"th Hello");
}
else if ((i%10) >= 4) System.out.println(i+"th Hello");
else if ((i%10) ==1) System.out.println(i+"st Hello");
else if ((i%10) == 2) System.out.println(i+"nd Hello");
else if ((i%10) == 3) System.out.println(i+"rd Hello");
else System.out.println(i+"th Hello");
i=i+1;
}
}
}