1. is my line 19 right? I want to add a number to the sum each time it loops..
2. how do I tell when a boolean is false - it that enough in my if statement line 21 ?
package com.codegym.task.task04.task0442;
/*
Adding
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner sc = new Scanner(System.in);
while (true) {
int number = sc.nextInt();
int sum = sum + number;
if (number == -1) {
System.out.println(sum);
break;
} else {
sum = sum + number;
}
}
sc.close();
}
}