-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab1.java
More file actions
29 lines (28 loc) · 796 Bytes
/
Lab1.java
File metadata and controls
29 lines (28 loc) · 796 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
/**
* C2 = 1 01 = "-"
* C3 = 2 C = 2
* C5 = 3 O2 = "+"
* C7 = 4, тип індексів i та j = float
*/
class Lab1 {
public static void main(String[] args) {
double S = 0;
int a = 4;
int b = 1;
int n = 6;
int m = 2;
int c = 2;
if (a <= c && c <= n){
System.out.println("Zero division error!");
System.exit(0);
}
for (float i = a; i <= n; i++) {
for (float j = b; j <= m; j++) {
S += (i + j) / (i - c);
}
}
S = S * 1000;
int k = (int) Math.round(S);
System.out.println ("Result = " + (double)k / 1000); //округлення числа до 3 знаків після коми
}
}