Question

Debugging Question: intArray[0] is initially 2, what is the first odd value that it is changed...

Debugging Question: intArray[0] is initially 2, what is the first odd value that it is changed to?

[Answer this question by taking a screenshot of your eclipse window while in debugger perspective showing both the Variables View and Expressions View.]

Code snippet:

for(int i = 0; i < 100000; i--)

{

int random_j = random.nextInt(intArray.length);

int random_k = random.nextInt(intArray.length);

int temp = intArray[random_j];

intArray[random_j] = intArray[random_k];

intArray[random_k] = temp;

}

Homework Answers

Answer #1

import java.util.Random;
import java.util.Arrays;
public class Main
{
   public static void main(String[] args) {
  
       int intArray[]=new int[100000];
       Random random = new Random();
       intArray[0]=2;
       for(int i = 0; i < 100000; i++)
{
int random_j = random.nextInt(intArray.length);

int random_k = random.nextInt(intArray.length);

int temp = intArray[random_j];

intArray[random_j] = intArray[random_k];

intArray[random_k] = temp;
  
if(((intArray[random_k] %2) != 0 )|| ((intArray[random_j] %2) !=0))
{
System.out.println(intArray[random_k]);   
}
}
  
   }
}

Please let me know if anything is required.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first...
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first node, and each node contains a pointer to the next node, and the pointer in the last node points back to the first node? A. Circular, singly-linked list. B. Circular, doubly-linked list. C. Singly-linked list. D. Doubly-linked list. E. None of the above.    QUESTION 2 _________ is not an advantage of linked lists when compared to arrays. A. Dynamic memory allocation. B. Efficient...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT