title: Output sum of even numbers between two integers
body: <p>I am working on a simple JAVA question in one of my college courses.  I am stumped on this one program.  I will display what I have so far and give the question I have to answer.  I also looked at a similar question on StackOverflow, BUT it isn't the same problem so it DIDN'T help. The program I need to write is:</p>
  
  <p>Write a program that uses 'while' loops to perform the following steps:</p>
  
  <p>a.) Prompt the user to input two integers: 'firstNum' and 'secondNum' (firstNum must be less than secondNum)</p>
  
  <p>b.) Output all the odd numbers between 'firstNum' and 'secondNum' inclusive.</p>
  
  <p>c.) Output the sum of all the even numbers between 'firstNum' and 'secondNum' inclusive.</p>
  
  <p>This is what I have so far... (I still need to calculate the even numbers and sum them up)</p>
  
  <pre><code>//import classes
  import java.util.*;
  
  public class chapter5no9
  {
      static Scanner console = new Scanner(System.in);
  
      public static void main(String[] args)
      {
  
      //Part A
      int firstNum;
      int secondNum;
      int sumEven;
  
      System.out.println("Please enter an integer: ");
      firstNum = console.nextInt();
  
      System.out.println("Please enter another integer less than the first integer: ");
      secondNum = console.nextInt();
  
      //Part B
      if (firstNum &lt; secondNum)
      {
          System.out.print("Your second number is greater than the first.  So Please re-enter: ");
          secondNum = console.nextInt();
      }
      else
      {
          System.out.print("Odd Numbers: ");
          firstNum++;
          while (firstNum &gt; secondNum)
          {
              if (secondNum % 2 != 0)
              {
                  System.out.print(" " + secondNum);
              }
              secondNum++;
          }
  
          System.out.println();
          System.out.print("Sum of Even Numbers: ");
          firstNum++;
          while (firstNum &gt; secondNum)
          {
              if (secondNum % 2 != 0)
              {
                  System.out.print(" " + secondNum);
              }
              secondNum++;
          }
      }
  }
  </code></pre>
  
  <p>}                                                                                                         </p>