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
Romashka [77]
3 years ago
11

Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that

will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Note: Generate 6 random index numbers in an attempt to fill the array. Create a method called printArray that prints the contents of the array using the for each enhanced loop. Submit code. Note: It is possible that your array won't be filled and some values will still have 0 stored. That is acceptable.
Computers and Technology
1 answer:
-Dominant- [34]3 years ago
3 0
<h2>Answer:</h2><h2></h2>

//import the Random and Scanner classes

import java.util.Random;

import java.util.Scanner;

//Begin class definition

public class ChangeUp {

   

   //Begin the main method

  public static void main(String args[]) {

       //Initialize the empty array of 6 elements

      int [] numbers = new int [6];

       

       //Call to the populateArray method

       populateArray(numbers);

       

       

   } //End of main method

   

   

   //Method to populate the array and print out the populated array

   //Parameter arr is the array to be populated

   public static void populateArray(int [] arr){

       

       //Create object of the Random class to generate the random index

       Random rand = new Random();

       

       //Create object of the Scanner class to read user's inputs

       Scanner input = new Scanner(System.in);

       

       //Initialize a counter variable to control the while loop

       int i = 0;

       

       //Begin the while loop. This loop runs as many times as the number of elements in the array - 6 in this case.

       while(i < arr.length){

           

           //generate random number using the Random object (rand) created above, and store in an int variable (randomNumber)

           int randomNumber = rand.nextInt(6);

       

           //(Optional) Print out a line for formatting purposes

           System.out.println();

           

           //prompt user to enter a value

           System.out.println("Enter a value " + (i + 1));

           

           //Receive the user input using the Scanner object(input) created earlier.

           //Store input in an int variable (inputNumber)

           int inputNumber = input.nextInt();

           

           

           //Store the value entered by the user in the array at the index specified by the random number

           arr[randomNumber] = inputNumber;

           

           

           //increment the counter by 1

          i++;

           

       }

       

       

       //(Optional) Print out a line for formatting purposes

       System.out.println();

       

       //(Optional) Print out a description text

      System.out.println("The populated array is : ");

       

       //Print out the array content using enhanced for loop

       //separating each element by a space

       for(int x: arr){

           System.out.print(x + " ");

       }

   

       

  } //End of populateArray method

   

   

   

} //End of class definition

<h2>Explanation:</h2>

The code above is written in Java. It contains comments explaining the lines of the code.

This source code together with a sample output has been attached to this response.

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
0d7446bcb6b48f78b8adbfa3da89789c.png
You might be interested in
Practice Home Survey
Ksivusya [100]

Answer:

Since this is a survey without preparation, you can move ahead as you like. However, still, you need to figure out the attributes. Here you need to register plugged in hours for each of your family members. And the same thing is abbreviated as screen time as well. You need to make a table with two columns, a family member's name, and the screen time or plugged in time. And you are not required to do anything else, as the survey is the method of collecting the data. And it does not deal with the analysis. The analysis will be done, when you will sit as an analyst. And in fact, you are making this impromptu survey for the family head, who is in charge of your family which can be your father or mother or your grand father or grand mother. And they can use these details for various findings, like how can they reduce cable TV cost per month, and so on. Your job is to collect the accurate data. And same thing, you need to repeat for all the survey that you are asked to conduct. Always remember, you need to know what data you need to collect through a survey. Plan for the survey only after finding the complete details about this. And even when asked to conduct as unprepared, this knowledge is essential.  

Explanation:

Please check the attachment.

5 0
4 years ago
Intellectual property piracy has gotten a small boost from the increasing availability of counterfeit goods through Internet cha
Aliun [14]

Answer:

The answer is "Option B".

Explanation:

Intellectual property is protected by law in which property, copyright, and trademarks, are uses, that enable you to gain individuals' popularity or personally benefit according to what they create.

  • It is a program that helps to create an environment, in which imagination and technology are used.
  • It will change the growth by striking a balance between innovator rights and wider public interest.
3 0
3 years ago
236. A system such as a printer, smart TV, or HVAC controller, typically uses an operating system on what is called a:
irakobra [83]

Answer:

Embedded System

5 0
2 years ago
Read 2 more answers
List 5 object which are considered part of ICT. explain its function.
UNO [17]

Answer:

Here it is

Explanation:

Processing is not considered as the tool of ICT. Explanation: ICT is Information and Communication Technology. This is one of the trending technologies with new concepts.

7 0
3 years ago
Provide an example of a question that could NOT be answered with a binary message. Explain why this is the case, making referenc
solong [7]
This is a question with a much simpler answer given its open ended ness - a representation merely means, given binary data, we can determine what 'thing' that binary data corresponds to.

<span>That makes the question unanswerable, because words can all be represented in binary data, and the question cannot be answered without those. Thus, all answers we can convey have a binary representation of some form (that form being the translation of the words we used to communicate the answer into binary data).</span>
7 0
4 years ago
Other questions:
  • based on the transcript, what did broadcasting the story through the medium of radio allow welles to do?
    8·1 answer
  • Which of the following is true of tape? Group of answer choices It is no longer used as a primary method of storage but is used
    10·1 answer
  • You would like the user of a program to enter a customer’s last name. Write a statement thaUse the variables k, d, and s so that
    5·1 answer
  • 1 Explain the difference between using a computer program and programming a computer.
    12·1 answer
  • While performing maintenance work on the components of a computer, you feel a small electric shock. Before you began working, yo
    5·1 answer
  • Why should ERP architecture include a discussion on organizational structure, business processes, and people, instead of just in
    5·1 answer
  • Write the definition of a function named max that receives an int parameter and returns the largest value that it has been calle
    12·1 answer
  • Which new console should i buy Nintendo switch Xbox series x or a ps5
    14·2 answers
  • I'll give brainlyist
    9·2 answers
  • One standard photo editing software programs for professionals is which of the following?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!