-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeWorkApp.java
More file actions
53 lines (46 loc) · 1.48 KB
/
Copy pathHomeWorkApp.java
File metadata and controls
53 lines (46 loc) · 1.48 KB
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
import java.util.Scanner;
public class HomeWorkApp {
public static void main(String[] args) {
printThreeWords();
checkSumSign(3, 6);
checkSumSign(-1, 1);
checkSumSign(-2, 1);
printColor(-7);
printColor(0);
printColor(7);
printColor(100);
printColor(101);
compareNumbers(9, 9);
compareNumbers(9, 5);
compareNumbers(3, 9);
}
public static void printThreeWords() {
System.out.println("Orange");
System.out.println("Banana");
System.out.println("Apple");
}
public static void checkSumSign(int a, int b) {
int sum = a + b;
if (sum >= 0) { // если сумма больше или равна нулю
System.out.println("Сумма положительная");
} else {
System.out.println("Сумма отрицательная");
}
}
public static void printColor(int value) {
if (value <= 0) {
System.out.println("Красный");
} else if (value <= 100){
System.out.println("Желтый");
} else if (value > 100){
System.out.println("Зеленый");
}
}
public static void compareNumbers(int a, int b) {
if (a >= b) {
System.out.println(a + " >= " + b);
} else {
System.out.println(a + " < " + b);
}
}
}