Created
November 18, 2013 20:47
-
-
Save fado/7535007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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