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
Active Questions
  • After reading Module 5 PowerPoint 1 - The Philosophy of Human Existance and Health Care Policy,...
    asked 2 minutes ago
  • 1. Do you feel play has a place in supporting literacy development in early childhood? Explain...
    asked 6 minutes ago
  • How should roles be selected for the Emergency Operations Center (EOC)?  Is seniority less important than experience?...
    asked 19 minutes ago
  • Discuss routing issues and solutions namely, count-to-infinity, split horizon, split horizon with poison reverse, and hold-down...
    asked 19 minutes ago
  • Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is〈5,10,3,12,5,50,6〉.
    asked 48 minutes ago
  • Water at 60 F (density=62.4lbm/ft^3 and dynamic viscosity = 7.5x10^-4 lbm/ft-s) is to be pumped through...
    asked 49 minutes ago
  • ibuprofen an aspirin substitute has the following percent composition C, 75.69%; H,8.80%; O,15.51%. determine the empirical...
    asked 49 minutes ago
  • Describe in brief some of the aspects of understanding words in the study of language
    asked 57 minutes ago
  • Anticipated sales for Safety Grip Company were 75,000 passenger car tires and 23,000 truck tires. Rubber...
    asked 1 hour ago
  • QUESTION ONE a) Differentiate between traceable and common costs b) Assume that you are living in...
    asked 1 hour ago
  • How do do you think that online course is different than the regular classroom setting experience
    asked 1 hour ago
  • MATLAB QUESTION: This must be completed using geometricrv. Please do not copy and paste the answer...
    asked 1 hour ago