title: How can i do while loop with scanner numbers up to 100 and their sum also will not be over 100
body: <pre><code>Scanner scanner = new Scanner(System.in);
  System.out.println(&quot;Enter number&quot;);
  
  int input = 0;
  int sum = 0;
  while (input != 100) {
      input  = scanner.nextInt();
      if (input + sum &gt; 100)
          break;
  
      sum += input;
  }
  
  System.out.println(&quot;Sum of Numbers : &quot; + sum);
  </code></pre>
  <p>I have the following task:</p>
  <ul>
  <li><p>Write a program that asks the user to enter a number.</p>
  </li>
  <li><p>If the number is less than 100, then ask user to enter another number
  and sum both of them.</p>
  </li>
  <li><p>Keep asking the user to enter numbers until the sum of all entered
  numbers is at least 100.</p>
  </li>
  </ul>
  <p>If the first number entered by the user is more than or equal to 100, print
  message “This number is already more than 100” and do not ask the user to enter any other numbers.</p>
  <p>I can print the sum of numbers entered by user but I just can't stop it. Even if I use <code>break</code>, it breaks after the 100 number.</p>