Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A)
- import java.util.Random;
- public class E1 {
- public static void main(String[] args) {
- int[] rando = new int[10];
- Random randomGenerator = new Random();
- int total = 0;
- for (int i = 0; i < rando.length; i++)
- {
- int randomInt = randomGenerator.nextInt(100);
- rando[i] = randomInt;
- if (i%2 == 0)
- {
- System.out.println(rando[i]);
- }
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- B)
- import java.util.Random;
- public class E1 {
- public static void main(String[] args) {
- int[] rando = new int[10];
- Random randomGenerator = new Random();
- int total = 0;
- for (int i = 0; i < rando.length; i++)
- {
- int randomInt = randomGenerator.nextInt(100);
- rando[i] = randomInt;
- if (randomInt%2 == 0)
- {
- System.out.println(rando[i]);
- }
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- C)
- import java.util.Random;
- public class E1 {
- public static void main(String[] args) {
- int[] rando = new int[10];
- Random randomGenerator = new Random();
- int total = 0;
- for (int i = 9; i >= 0; i--)
- {
- int randomInt = randomGenerator.nextInt(100);
- rando[i] = randomInt;
- if (randomInt%2 == 0)
- {
- System.out.println(rando[i]);
- }
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- D)
- import java.util.Random;
- public class E1 {
- public static void main(String[] args) {
- int[] rando = new int[10];
- Random randomGenerator = new Random();
- int total = 0;
- for (int i = 0; i < rando.length; i++)
- {
- int randomInt = randomGenerator.nextInt(100);
- rando[i] = randomInt;
- if (i == 0)
- {
- System.out.println(rando[i]);
- }
- if (i == 9)
- {
- System.out.println(rando[i]);
- }
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement