Files
OOP_IO-2x_2023-mirror/lab1/src/Main.java

22 lines
598 B
Java
Raw Normal View History

2023-02-22 20:28:48 +01:00
public class Main {
public static void main(String[] args) {
2023-02-24 08:25:42 +01:00
float s = 0.0f, a = 2.0f, b = 1.0f, m = 6.0f, n = 4.0f;
int c = 1;
2023-02-22 20:28:48 +01:00
for (float i = a; i <= m; i++) {
2023-02-24 08:25:42 +01:00
// Перевірка ділення на 0.
if (i == -1) {
System.out.println("Помилка: ділення на нуль не можливе.");
return;
}
2023-02-22 20:28:48 +01:00
for (float j = b; j <= n; j++) {
2023-02-24 08:25:42 +01:00
s += (i + j) / (i + c);
2023-02-22 20:28:48 +01:00
}
}
System.out.println("S = " + s);
}
}