title: How to add user inputted data using an array and displaying it?
body: <p>I am creating a program which involves the user having to input data about a game in a certain format, they will enter several pieces of information which i then have to display to them including total score and total time played of the games they enter. I am currently doing this using an array to store the information but i can not work out how to add up all the data they have given me. This is what i have so far.</p>
  
  <pre><code>//setting up my array.
  
      myArray = input.split(":");
      score = Integer.parseInt(myArray[1]);
      timePlayed = Integer.parseInt(myArray[2]);
  </code></pre>
  
  <p>This is me setting up the array splitter.</p>
  
  <pre><code>do {
      numGames++;
      System.out.println("Enter game information seperated with colons. Example - Game:Score:Mins");
      input = scanner.nextLine();
  </code></pre>
  
  <p>This is where i prompt the user to enter the data in my requested format. This will be repeated until they enter 'quit' or reach the game limit of 20.</p>
  
  <pre><code>        }while  (!input.equalsIgnoreCase("quit") &amp;&amp; numGames &lt;20);
      System.out.println("Player: " + player );
      System.out.println("- - - - - - - - - - - - -");
      System.out.println("Games played: " + numGames + ", " + "Score: " +  score + ", " + "Time played: " + timePlayed);
  </code></pre>
  
  <p>I then want the information to be displayed like this, however when i run my program it does not add up the combined game time, the number of games count works but the score and time played does not.</p>
  
  <p>Sorry if this is not formatted correctly as it is my first post! If you guys need any more info or code from my program to help me just let me know and I will try! Thanks a bunch! :)</p>
  
  <p>Requested full code:</p>
  
  <pre><code> String input;
      String player;
      int score;
      int timePlayed;
      float scores;
      float time;
      Scanner scanner = new Scanner (System.in);
      int numGames = 0;
  System.out.print("Enter your name: ");
          player = scanner.nextLine();
  
                      //If the player does not enter a name they are them prompted to do so again until they have.
  
          while (player.isEmpty())
          {
              System.out.print("Enter your name: ");
              player = scanner.nextLine();
          }
          String[] myArray = new String [2];
  
  
          //This section is prompting the player to input game data in a format requested.
  
          do {
          numGames++;
          System.out.println("Enter game information seperated with colons. Example - Game:Score:Mins");
          input = scanner.nextLine();
  
  
          //If the player does not enter any information then this piece of code will run and ask them to do so.
          while (input.isEmpty())
          {
              System.out.println("Enter game information seperated with colons. Example - Game:Score:Mins");
              input = scanner.nextLine();
  
          }
  
          //setting up my array.
  
          myArray = input.split(":");
          score = Integer.parseInt(myArray[1]);
          timePlayed = Integer.parseInt(myArray[2]);
  
  
          //This displays to the player what they have just entered.
          System.out.println("Player: " + player );
          System.out.println("- - - - - - - - - - - - -");
          System.out.println("Games played: " + numGames + ", " + "Score: " + score + ", " + "Time played: " + timePlayed);
  
          input = scanner.nextLine();
  
          try{
              scores = Float.parseFloat(myArray[1]);
              time = Float.parseFloat(myArray[2]);
          }
  
          catch (NumberFormatException e) {
                 System.out.println("Error: invalid input, not a number" + e.getMessage());
  
              }
          input = scanner.nextLine();
  
          score.add(myArray[0]);
  
          }while  (!input.equalsIgnoreCase("quit") &amp;&amp; numGames &lt;2);
          System.out.println("Player: " + player );
          System.out.println("- - - - - - - - - - - - -");
          System.out.println("Games played: " + numGames + ", " + "Score: " +  score + ", " + "Time played: " + myArray[2]);
  
  
      System.out.println("Exit");
  
      scanner.close();
  </code></pre>