Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args)
- {
- int limit = 0;
- int sum = 0;
- Scanner scan = new Scanner(System.in);
- System.out.print("Enter Limit: ");
- limit = scan.nextInt();
- System.out.println();
- System.out.println("Sum of the even numbers between 2 and " + limit + " (inclusive) are:");
- for (int count = 1; count <= limit; count++)
- {
- // Needed if ever even
- if((count & 1)!= 1)
- {
- sum+=count;
- System.out.println(count);
- }
- }
- System.out.println("Total sum is " + sum);
- }`
Add Comment
Please, Sign In to add comment