public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int userInput;
int sum = 0;
System.out.println("Enter numbers (enter '0' to finish): ");
while ((userInput = in.nextInt()) != 0) {
sum += Math.pow(userInput, 2);
}
System.out.println("Your result sum is: " + sum);
Written in Java PL
#Python
_sum = 0
x = float(input())
while x != 0:
_sum += x**2
print(_sum)
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int userInput;
int sum = 0;
System.out.println("Enter numbers (enter '0' to finish): ");
while ((userInput = in.nextInt()) != 0) {
sum += Math.pow(userInput, 2);
}
System.out.println("Your result sum is: " + sum);
}
Written in Java PL
Verified answer
#Python
_sum = 0
x = float(input())
while x != 0:
_sum += x**2
x = float(input())
print(_sum)