-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
143 lines (142 loc) · 5.23 KB
/
Main.java
File metadata and controls
143 lines (142 loc) · 5.23 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Выберите задание(1-10)");
int task = keyboard.nextInt();
switch (task) {
case 1: // 1 задание
double a = keyboard.nextInt();
double p = 4 * a;
System.out.println("p=" + p);
break;
case 2: // 2 задание
System.out.println("Введите количество сантиметров");
double san = keyboard.nextInt();
double met = san / 100;
System.out.println("Сантиметров в метрах:" + met);
break;
case 3: // 3 задание
System.out.println("Введите числа a и c");
double a2 = keyboard.nextInt();
double c = keyboard.nextInt();
System.out.println("Введите число b");
double b = keyboard.nextInt();
if (b > a2 && b < c || b < a2 && b > c) {
System.out.println("Число b между чисел a и c");
} else {
System.out.println("Число b не между чисел a и c");
}
break;
case 4: // 4 задание
double sum;
System.out.println("Введите число а");
double a3 = keyboard.nextInt();
System.out.println("Введите число b");
double b2 = keyboard.nextInt();
System.out.println("Введите число c");
double c2 = keyboard.nextInt();
if (a3 < b2 && a3 < c2) {
sum = b2 + c2;
System.out.println("Сумма наибольших чисел =" + sum);
} else if (b2 < a3 && b2 < c2) {
sum = a3 + c2;
System.out.println("Сумма наибольших чисел =" + sum);
} else if (c2 < a3 && c2 < b2) {
sum = a3 + b2;
System.out.println("Сумма наибольших чисел =" + sum);
}
break;
case 5: // 5 задание
System.out.println("Введите z");
double z = keyboard.nextInt();
System.out.println("Введите x");
double x = keyboard.nextInt();
System.out.println("Введите y");
double y = keyboard.nextInt();
double b3;
double a4;
b3 = 1 + (Math.pow(z, 2) / (3 + (Math.pow(z, 2) / 5)));
a4 = (2 * Math.sin(x - (Math.PI / 6)) * b3) / (0.5 + Math.pow(Math.sin(y), 2));
System.out.println("a=" + a4);
break;
case 6: // 6 задание
double z2;
System.out.println("Ведите x");
double x2 = keyboard.nextInt();
System.out.println("Введие y");
double y2 = keyboard.nextInt();
double s;
int fac1 = 1;
int fac2 = 1;
int fac3 = 1;
z2 = Math.sin(Math.pow(x2, 3)) + Math.pow(Math.cos(y2), 2);
for (int i = 1; i < 3; i++) {
fac1 = fac1 * i;
}
for (int i = 1; i < 4; i++) {
fac2 = fac2 * i;
}
for (int i = 1; i < 5; i++) {
fac3 = fac3 * i;
}
s = 1 + x2 + Math.pow(x2, 2) / fac1 + Math.pow(x2, 3) / fac2 + Math.pow(x2, 4) / fac3;
System.out.println("z=" + z2);
System.out.println("s=" + s);
break;
case 7: // 7 задание
int index = keyboard.nextInt();
switch (index) {
case 1:
System.out.println("Понедельник");
break;
case 2:
System.out.println("Вторник");
break;
case 3:
System.out.println("Среда");
break;
case 4:
System.out.println("Четверг");
break;
case 5:
System.out.println("Пятница");
break;
case 6:
System.out.println("Суббота");
break;
case 7:
System.out.println("Воскресенье");
break;
default:
System.out.println("error");
break;
}
case 8: // 8 задание
System.out.println("Введите n");
double n = keyboard.nextInt();
double i = 0;
double result;
for (result = 0; result != Math.pow(n * 2, 2); i++) {
result = Math.pow(n, 2) + Math.pow(n + i, 2) + result;
}
System.out.println("Result=" + result);
break;
case 9: // 9 задание
System.out.println("Введие n");
int n9 = keyboard.nextInt();
if ( n9 % 3 == 0 || n9 ==3 || n9 == 9) {
System.out.println("True");
} else {
System.out.println("False");
}
break;
case 10: // 10 задание
System.out.println("Введие строку из чисел");
String n3 = keyboard.next();
boolean result3 = n3.contains("2");
System.out.println(result3);
break;
}
}
}