Skip to content

Instantly share code, notes, and snippets.

@fado
Created November 18, 2013 20:47
Show Gist options
  • Save fado/7535007 to your computer and use it in GitHub Desktop.
Save fado/7535007 to your computer and use it in GitHub Desktop.
package uk.ac.qub.programming;
import java.util.ArrayList;
public class PartSix {
/**
* @param args
*/
public static void main(String[] args) {
ArrayList<Integer> evenNumbers = new ArrayList<Integer>();
int total = 0;
for (int counter = 1; counter < 101; counter++) {
if (counter%2 == 0) {
evenNumbers.add(counter);
}
}
System.out.println(evenNumbers.toString());
for (int number : evenNumbers) {
total += number;
}
System.out.println("Total: "+total);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment