daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Nov 13th, 2018 84 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. public static void main(String[] args)
  2. {
  3.     int limit = 0;
  4.     int sum   = 0;
  5.  
  6.     Scanner scan = new Scanner(System.in);
  7.  
  8.     System.out.print("Enter Limit: ");
  9.     limit = scan.nextInt();
  10.  
  11.     System.out.println();
  12.     System.out.println("Sum of the even numbers between 2 and " + limit + " (inclusive) are:");
  13.  
  14.     for (int count = 1; count <= limit; count++)
  15.     {
  16.         // Needed if ever even
  17.  
  18.         if((count & 1)!= 1)
  19.         {
  20.             sum+=count;
  21.             System.out.println(count);
  22.         }
  23.     }
  24.     System.out.println("Total sum is " + sum);
  25.    
  26. }`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top