#Must input two numbers for the program to output back a message

1 messages · Page 1 of 1 (latest)

shrewd jayBOT
#

<@&987246399047479336> please have a look, thanks.

#

System.out.print("Enter a number (or 0 to exit): ");
int num = scanner.nextInt();

        if(num == 0){
            break;
        }
        
        sum += num;
    }
    
    System.out.println("The sum of the numbers is: " + sum);
}

}

white talon
#

well yes, since there are two nextInt

tranquil juniper
#

would it be better just to assign nextInt to a variable

white talon
#

yes