-
Notifications
You must be signed in to change notification settings - Fork 1
/
CozaLozaWoza.java
42 lines (33 loc) · 1.21 KB
/
CozaLozaWoza.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class CozaLozaWoza {
public static void main(String[] args) {
/*
* 9. Write a program called CozaLozaWoza which prints the number 1 to 110, 11
* numbers per line. The program shall print "Coza" in place of the numbers
* which are multiples of 3, "Loza" for multiples of 5, "Woza" for multiples of
* 7, "CozaLoza" for multiples of 3 and 5, and so on. The output shall look
* like:
*
* 1 2 Coza 4 Loza Coza Woza 8 Coza Loza 11 Coza 13 Woza CozaLoza 16 17 Coza 19
* Loza CozaWoza 22 23 Coza Loza 26 Coza Woza 29 CozaLoza 31 32 Coza
*/
for (int i = 1; i <= 110; i++) {
if (i % 3 == 0 & i % 5 == 0) {
System.out.print(" CozaWoza ");
}
else if (i % 5 == 0) {
System.out.print(" Loza ");
}
else if (i % 7 == 0) {
System.out.print(" Woza ");
}
else if (i % 3 == 0) {
System.out.print(" Coza ");
}
else {
System.out.print(String.valueOf(i));
}if (i % 11==0) {
System.out.println();
}
}
}
}