Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chapter6;
- import java.util.Random;
- public class Asdf
- {
- public static void main(String[] args)
- {
- Random rand = new Random();
- int[] a = new int[10];
- // Part A
- for (int i = 0; i < 10; i++)
- {
- a[i] = rand.nextInt(100);
- }
- //Part B
- for(int i = 0; i <= 10; i++)
- {
- if (a[i]%2 == 0)
- {
- System.out.println("Even Element");
- System.out.println(a[i]);
- }
- }
- //Part C
- for(int i = 0; i <= 10; i++)
- {
- if (i%2 == 0)
- {
- System.out.println("Element At Even index");
- System.out.println(a[i]);
- }
- }
- //Part D
- for(int i = 10; i >= 0; i--)
- {
- System.out.print(a[i] + " ");
- }
- for(int i = 0; i <= 10; i++)
- {
- System.out.print(a[10]);
- System.out.print(" ");
- System.out.print(a[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement