-
Notifications
You must be signed in to change notification settings - Fork 1
/
IntroControl.java
77 lines (64 loc) · 1.63 KB
/
IntroControl.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package introcontrol;
public class IntroControl {
public int subtractTenIfGreaterThanTen(int number) {
if (number <= 10) {
return number;
} else {
return number - 10;
}
}
public String describeNumber(int number) {
if (number==0) {
return "zero";
} else {
return "not zero";
}
}
public String greetingToJoe(String name) {
if (name.equals("Joe")) {
return "Hello Joe";
} else {
return "";
}
}
public int calculateBonus(int sale) {
if (sale >= 1000000) {
return (int) (sale * 0.1);
} else {
return 0;
}
}
public int calculateConsumption(int prev, int next) {
if (prev <= next) {
return next - prev;
} else {
return 10000 - prev + next;
}
}
public void printNumbers(int max) {
for (int i = 0; i <= max; i++) {
System.out.println(i);
}
}
public void printNumbersBetween(int min, int max) {
for (int i = min; i <= max; i++) {
System.out.println(i);
}
}
public void printNumbersBetweenAnyDirection(int a, int b) {
if (a > b) {
for (int i = a; i >= b; i--) {
System.out.println(i);
}
} else {
for (int i = a; i >= b; i++) {
System.out.println(i);
}
}
}
public void printOddNumbers(int max) {
for (int i = 1; i <= max; i = i + 2) {
System.out.println(i);
}
}
}