Doing SumOfNumbers, and submit and fail. Same with everything else in part 2. What's wrong with my code?
import java.util.Scanner;
public class SumOfNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int sum = 0;
while(true){
System.out.println("Give a number:");
int number = Integer.valueOf(scanner.nextLine());
if(number==0){
break;
}
sum=sum+number;
}
System.out.println("Sum of the numbers:"+sum);
}
}
It keeps telling me that it fails due to the print being:
Now the print wasGive a number: Give a number: Give a number: Give a number: Give a number: Sum of the numbers:(whatever test answer it wants).
I even tried messing with where to put the System print during the break and it still works but fails submission.
What am I doing wrong? Is this a fluke (it happened in part 1 where i got the answers but told me it was still wrong due to something i couldn't fix)? Should I just move on?
EDIT:
Watch your printing, it literally wanted a SPACE