1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dmitry [639]
3 years ago
14

Write a program that initializes an array with ten random integers and then prints four lines of output, containing (Horstmann,

01/2013) Horstmann, C. S. (01/2013). Big Java: Early Objects, 5th Edition [VitalSource Bookshelf version]. Retrieved from vbk://9781118545997 Always check citation for accuracy before use.
Computers and Technology
1 answer:
Amiraneli [1.4K]3 years ago
8 0

Answer:

import java.util.Scanner;

import java.util.Random;

public class Solution

{

public static void indexEven(int[] randomNumbers)

{

System.out.print("Even index elements are: ");

for (int i = 0; i < randomNumbers.length; i++)

{

if (i % 2 == 0)

{

System.out.print(randomNumbers[i] + " ");

}

}

System.out.println();

}

public static void evenelement(int[] randomNumbers)

{

System.out.print("Every even element: ");

for (int i = 0; i < randomNumbers.length; i++)

{

if (randomNumbers[i] % 2 == 0)

{

System.out.print(randomNumbers[i] + " ");

}

}

System.out.println();

}

public static void reverseOrder(int[] randomNumbers)

{

System.out.print("All elements in reverse order: ");

for (int i = randomNumbers.length - 1; i >= 0; i--)

{

System.out.print(randomNumbers[i] + " ");

}

System.out.println();

}

public static void firstLast(int[] randomNumbers)

{

System.out.print("First and last elements are: ");

System.out.print(randomNumbers[0] + " " + randomNumbers[randomNumbers.length - 1]);

System.out.println();

}

public static void main(String[] args)

{

// create instance of Random class

Random rand = new Random();

System.out.print("Array: ");

int[] randomNumbers = new int[10];

for (int i = 0; i < randomNumbers.length; i++)

{

randomNumbers[i] = rand.nextInt(100);

System.out.print(randomNumbers[i] + " ");

}

System.out.println();

indexEven(randomNumbers);

evenelement(randomNumbers);

reverseOrder(randomNumbers);

firstLast(randomNumbers);

}

}

Explanation:

You might be interested in
Four differences between fourth and fifth generation of computers​
Juliette [100K]

Answer:

 The following are the four difference between the fourth and the fifth generation of the computer that are:

  • The fourth generation computer technology is basically based of the microprocessor. On the other hand, the fifth generation computer is based upon the artificial intelligence technology.  
  • The fourth generation computer system are faster in computation. Whereas, the fifth generation computer are more reliable and faster in speed as compared to all other generations.
  • The fifth generation computer are small in the size and more potable as compared to the fourth generation computer system.
  • Laptop, notebook and Chromebook are some of the example of fifth generation. Whereas, STAR 100 and IBM 4341 are the example of fourth generation.
7 0
3 years ago
What happens if i receive a text while my phone is off?
SIZIF [17.4K]
The text will post to your phone when it gets turned on
4 0
4 years ago
If you want to open an application that does not have a tile pinned to the start menu
guapka [62]
Search for it in the start menu. Once you find it, right click and press "Pin to taskbar."
6 0
3 years ago
What is the recommended solution to configure this automated behavior? UC has a requirement that an opportunity should have a fi
Dmitry_Shevchenko [17]
The answer will need to be workflow.
8 0
4 years ago
Which terms describes Benito Mussolini’s form of government
slega [8]
The political system that describes Benito Mussolini’s form of government would be totalitarian.Hope this answers the question:)
5 0
4 years ago
Read 2 more answers
Other questions:
  • Does toontown rewritten carry spyware or malware
    9·1 answer
  • Peak download rate for a 4g network is __________. select one:
    12·2 answers
  • )1-bit sign, 8-bit exponent, 23-bit fraction and a bias of127 is used for ___________ Binary Floating PointRepresentation
    11·1 answer
  • If you wanted to round $3.99 located in Cell B3 to the nearest dollar, what is the correct Microsoft excel formula?
    6·2 answers
  • Differentiate among web apps, mobile apps, and mobile web apps.
    14·2 answers
  • Password is an example of an authentication mechanisms that is based on " what an entity has".
    6·2 answers
  • What is the forging of the return address on an email so that the email message appears to come from someone other than the actu
    11·1 answer
  • Write the algorithm for finding the perimeter of a rectangle using English like form step by step
    10·1 answer
  • A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.
    13·1 answer
  • A network of computers that provides access to information on the web.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!