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
HELP!!!
aleksley [76]

Answer:

The detail answer of this question is given in explanation section.

The simple answer is option B

Explanation:

Let took at each option:

A) an html tag

An html tag is used to start and end html document. It does not have anything to do with rendering.

B) a doctype declaration

The document type declaration is necessary because it tell the browser which version of html should be rendered.

C)Body tag tell the browser. it is the visible area of website.

D) A hear tag is used to clear meta data about website.

3 0
2 years ago
Read 2 more answers
......... mi2hej<br><br>ejid8eo19o1b2bxhxjxjdnneejk2929nr
Mila [183]

Answer:

hi  thsu si s5

Explanation:

brace use

5 0
2 years ago
Read 2 more answers
Suppose you have a 16-bit machine with a page size of 16B. Assume that any unsigned 16-bit integer can be a memory address. Also
irinina [24]

Answer:

2^11

Explanation:

Physical Memory Size = 32 KB = 32 x 2^10 B

Virtual Address space = 216 B

Page size is always equal to frame size.

Page size = 16 B. Therefore, Frame size = 16 B

If there is a restriction, the number of bits is calculated like this:  

number of page entries = 2^[log2(physical memory size) - log2(n bit machine)]

where

physical memory size = 32KB  which is the restriction

n bit machine = frame size = 16

Hence, we have page entries = 2^[log2(32*2^10) - log2(16)] = 2ˆ[15 - 4 ] = 2ˆ11

7 0
3 years ago
What are the best 3 xbox 360 games ?​
Andru [333]
Halo
GTA
Call of duty
5 0
3 years ago
Read 2 more answers
An Operating System is an application just like any other applications we use on our
Pie

Answer:

Level of operation

Explanation:

The operating system is the system that enables other software to run on a device. It therefore handles the data between the user and the different features of the hardware, such as hosting device drivers. It also determines the core language used on the device, such as Windows, apple or Linux. This provides conformity accross devices allowing software and hardware companies to produce compatible products.

6 0
3 years ago
Other questions:
  • Under what conditions might the Justice Department approve a merger between two companies that operate in an industry with a pos
    14·1 answer
  • You're creating a table for one of your slides, and need to make some modifications to your table structure. Which of the follow
    14·1 answer
  • Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g
    7·2 answers
  • You’re creating a table for one of your slides, and need to make some modifications to your table structure. Which of the follow
    6·2 answers
  • Mention<br>any<br>5<br>indicators of<br>happiness​
    11·2 answers
  • Dr. Kim divides a programming class into groups. Each group will create a large program as their
    15·2 answers
  • What are the peripherals of a computer ​
    12·1 answer
  • Choose the correct answer
    6·1 answer
  • How was data put into the Tabulating Machine?
    7·1 answer
  • How do we find the time complexity for this algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!