title: Java - cumulative sum of integer input doesnt work in while loop
body: <p>Im having trouble figuring out why my code doesnt work. First off, Im new to Java so bear with me.
  The task is:
  Write a program that reads a sequence of integer inputs and prints the cumulative totals. If the input is 1 7 2 9, the program should print 1 8 10 19.</p>
  
  <pre><code>package lektion05forb;
  
      import java.util.Scanner;
  
  /**
   *
   * @author Lars
   */
  public class P52LoopsC 
  {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) 
  {
  
      Scanner input = new Scanner(System.in);
      System.out.print("Numbers: ");
      double cumulative_sum = 0;
      String output_cumulative_sum= "";
  
      while (input.hasNextDouble())
      {
          double input_number = input.nextDouble();
          cumulative_sum += input_number;
          output_cumulative_sum += String.format("%s ", String.valueOf(cumulative_sum));
          break;
      }
      input.close();
      System.out.println(output_cumulative_sum);
  }
  
  }
  </code></pre>
  
  <p>When I input a sequence of numbers like 3 4 5 8 2, it returns with 34582, instead of the cumulative sum of the numbers. Can anyone explain why, and how i can fix it so it returns the cumulative total of the sequence?</p>