title: Finding sum of values in map java
body: <p>I am beginner to Java, so I am learning through experimentation. I wanted to create a class where it would take a type of ride as a String and number of riders as an Integer. I decided to use Map because it would allow me to keep together a ride type with its pertinent # of individuals.</p>
  
  <pre><code>//How many attendants in total
  System.out.println("How many attendents today?: ");
  int numberOfAttendents = Integer.parseInt(bf.readLine());
  System.out.println("Total number of attendents: " + numberOfAttendents);
  
  Map&lt;String, Integer&gt; typeOfRide = new HashMap&lt;String, Integer&gt;();
  boolean run = true;
  final String counterEnd = "stop";
  while(run)
  {
     System.out.println("What type of ride?: ");
     String nameOfType = bf.readLine();
     if(nameOfType.equalsIgnoreCase(counterEnd))
     {
        run = false;
     }
     else
     {
       System.out.println("Number of riders?: ");
       Integer numberPerType =    Integer.parseInt(bf.readLine());                
       typeOfRide.put(nameOfType, numberPerType);
      }   
   }
  </code></pre>
  
  <p>So the above part compiles with no problem. However when I try to add the number of riders per ride type, I am having some difficulty try to come up with a way. I understand the enhanced for loop I used is for arrays and not for map.</p>
  
  <pre><code> //Adding individual entries of same ride
     for(Integer i: typeOfRide)
     {
        int sum = 0;
        System.out.println("Which ride type?: ");
        String typeNumber = bf.readLine();
        sum = sum + typeOfRide.get(typeNumber);
        System.out.println("Total number of riders per" + typeNumber + ":" + sum);
      }
  </code></pre>
  
  <p>So if y'all can suggest a method to get the sum, I would appreciate. Thanks!</p>