-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfever.java
More file actions
39 lines (28 loc) · 708 Bytes
/
Copy pathfever.java
File metadata and controls
39 lines (28 loc) · 708 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
27
28
29
30
31
32
33
34
35
36
37
38
39
public class fever {
// Bieber Fever challenge:
// 1: Write a program that uses a for loop to print
// baby
// baby
// baby
// oh
// Code should only contain one “baby”, and one “oh”
// 2: Every 2nd time the “oh” should be “no”
//
// /3: Each chorus ends with “I thought you'd always be mine”.
public static void main(String[] args) {
for (int a = 0; a < 2; a++) {
if (a % 2 == 1) {
System.out.println("like");
}
for (int i = 0; i < 3; i++) {
System.out.println("baby");
}
if (a % 2 == 1) {
System.out.println("no");
} else {
System.out.println("oh");
}
}
System.out.println("I thought you'd always be mine");
}
}