forked from ugurcankeser/Java-IAU
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomArraySum.java
More file actions
68 lines (49 loc) · 1.16 KB
/
RandomArraySum.java
File metadata and controls
68 lines (49 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package pack1;
import java.util.Random;
public class Arrays {
public static void list(int[] array, int length){
for(int i=0; i<5;i++)
{
System.out.print(array[i]+" ");
}
System.out.println();
}
public static void main(String[] args)
{
/*int[] array1=new int[5];
int[] array2={3,5,7,8,2};
int length=array1.length; //Gives length of array assign to length*/
int[] array1=new int[5];
int[] array2=new int[5];
int[] result=new int[5];
Random rnd=new Random();
for(int i=0;i<5;i++)
{
array1[i]=rnd.nextInt(11)+10;
array2[i]=rnd.nextInt(11)+10;
result[i]=array1[i]+array2[i];
}
list(array1,array1.length);
list(array2,array2.length); //İnstead of below for
list(result,result.length);
/*for(int i=0; i<5;i++)
{
System.out.print(array1[i]+" ");
}
System.out.println();
for(int i=0; i<5;i++)
{
System.out.print(array1[i]+" ");
}
System.out.println();
for(int i=0; i<5;i++)
{
System.out.print(array2[i]+" ");
}
System.out.println();
for(int i=0; i<5;i++)
{
System.out.print(result[i]+" ");
}*/
}
}