Last active
August 29, 2015 14:05
-
-
Save lb7n/2fbc5298febc79e9aa7c to your computer and use it in GitHub Desktop.
program that calculates the average of 2 random numbers looping it 1000 times and saving to an array list
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 loop; | |
import java.util.ArrayList; | |
public class Mainclass { | |
public static void main(String[] args) | |
{ | |
ArrayList<Integer> Random = new ArrayList<Integer>(); | |
int upperBound = 1000; | |
int lowerBound = 1; | |
for(int i=0; i<upperBound; i++){ | |
int randomNumber = (int)(Math.random() * ((upperBound - lowerBound) + 1) + lowerBound); | |
int randomNumber2 = (int)(Math.random()* ((upperBound - lowerBound) + 1)+ lowerBound); | |
int x = (randomNumber + randomNumber2)/2; | |
Random.add(x); | |
System.out.println(x); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment