-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeWorkApp2.java
More file actions
40 lines (37 loc) · 1.05 KB
/
Copy pathHomeWorkApp2.java
File metadata and controls
40 lines (37 loc) · 1.05 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
package lesson2;
public class HomeWorkApp2 {
public static void main(String[] args) {
System.out.println(within10and20(15, 6));
PositiveOrNegative(45);
System.out.println(isNegative(-78));
printWordNTimes("str", 4);
System.out.println(isLeapYear(2022));
}
//1)
public static boolean within10and20(int x1, int x2) {
int y = x1 + x2;
return y >= 10 && y <= 20;
}
//2)
public static void PositiveOrNegative(int x) {
if (x >= 0) {
System.out.println("Положительное число");
} else {
System.out.println("Отрицательное число");
}
}
//3)
public static boolean isNegative(int x) {
return x < 0;
}
//4)
public static void printWordNTimes(String word, int times) {
for (int i = 0; i < times; i++) {
System.out.println(word);
}
}
//5)
public static boolean isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
}