import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("a: ");
int a = in.nextInt();
System.out.print("b: ");
int b = in.nextInt();
int s = 0;
while (b < a) {
System.out.println("Error b>=a");
b = in.nextInt();
}
b = b + 1;
for (int i = a;b > i; i++) {
s += i*i;
System.out.print(s);
Объяснение:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("a: ");
int a = in.nextInt();
System.out.print("b: ");
int b = in.nextInt();
int s = 0;
while (b < a) {
System.out.println("Error b>=a");
System.out.print("b: ");
b = in.nextInt();
}
b = b + 1;
for (int i = a;b > i; i++) {
s += i*i;
}
System.out.print(s);
}
}
Объяснение: