2023-03-22 17:02:31 +02:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
public class Lab_1 {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
int n, m, a, b;
|
|
|
|
float s = 0;
|
|
|
|
|
|
|
|
Scanner input = new Scanner(System.in);
|
|
|
|
|
2023-05-02 09:58:31 +03:00
|
|
|
do {
|
|
|
|
try {
|
|
|
|
System.out.print("Enter n: ");
|
|
|
|
n = input.nextInt();
|
|
|
|
break;
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("N must be an integer.");
|
|
|
|
input.nextLine();
|
|
|
|
}
|
|
|
|
} while (true);
|
2023-03-22 17:02:31 +02:00
|
|
|
|
2023-05-02 09:58:31 +03:00
|
|
|
do {
|
|
|
|
try {
|
|
|
|
System.out.print("Enter m: ");
|
|
|
|
m = input.nextInt();
|
|
|
|
break;
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("M must be an integer.");
|
|
|
|
input.nextLine();
|
|
|
|
}
|
|
|
|
} while (true);
|
2023-03-22 17:02:31 +02:00
|
|
|
|
|
|
|
do {
|
2023-05-02 09:58:31 +03:00
|
|
|
try {
|
|
|
|
System.out.print("Enter a: ");
|
|
|
|
a = input.nextInt();
|
|
|
|
break;
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("A must be an integer.");
|
|
|
|
input.nextLine();
|
|
|
|
}
|
|
|
|
} while (true);
|
2023-03-22 17:02:31 +02:00
|
|
|
|
|
|
|
do {
|
2023-05-02 09:58:31 +03:00
|
|
|
try {
|
|
|
|
System.out.print("Enter b: ");
|
|
|
|
b = input.nextInt();
|
|
|
|
break;
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("B must be an integer.");
|
|
|
|
input.nextLine();
|
|
|
|
}
|
|
|
|
} while (true);
|
2023-03-22 17:02:31 +02:00
|
|
|
|
2023-04-26 14:37:46 +03:00
|
|
|
input.close();
|
|
|
|
|
2023-05-02 09:58:31 +03:00
|
|
|
for (int i = a; i <= n; i++) {
|
|
|
|
for (int j = b; j <= m; j++) {
|
|
|
|
s += j;
|
2023-03-22 17:02:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("S = " + s);
|
|
|
|
}
|
|
|
|
}
|