I am currently working on a problem set for an assignment at school, and I’m really close to finishing however I’m getting a few compilation errors. The problem set includes displaying the weeks avg. temp, highest temp., lowest temp., and the days of the week that are hottest and coldest. Currently what I’m trying to do is display the days
Tag: arrays
Calculate factorial of 50 using array only in java
I’m a total beginner of java. I have a homework to write a complete program that calculates the factorial of 50 using array. I can’t use any method like biginteger. I can only use array because my professor wants us to understand the logic behind, I guess… However, he didn’t really teach us the detail of array, so I’m really
ATM Machine in Java
I have been trying to figure out what is going wrong with this program I’m writing. Heres the full description of what I’m trying to do: Use the Account class created in Programming Exer- cise 9.7 to simulate an ATM machine. Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100.
How to [flat] merge Merge Multiple Arrays into List in Java
How can I [flat] merge multiple arrays into a single List<String>? For example: Answer Assuming that you wish to add the array of Integers into the same List of Strings:
Does a synchronized block trigger a full memory fence for arrays?
I am confused about sharing arrays safely between threads in Java, specifically memory fences and the keyword synchronized. This Q&A is helpful, but does not answer all of my questions: Java arrays: synchronized + Atomic*, or synchronized suffices? What follows is sample code to demonstrate the issue. Assume there is a pool of worker threads that populates the SharedTable via
How to convert an String Variable with Array to an Integer Variable with Array
I am new to java programming. I am trying to convert an string variable with array to an int variable array but i have 2 errors and have no idea to fix it, any help would be great, thanks.. This is my source code : This is what the errors look like Answer Try below code, it is working.
Finding the mode of a 2D array
I’m trying to return the mode of a 2D array using a frequency array. I have an array, score, which is of length 10, and has 3 columns. Each column contains an int that is between 0 and 100. I’m trying to find a way that will iterate through the array and return the modal value. What I have so
Generating 10 random numbers without duplicate with fundamental techniques
my intend is to use simplest java (array and loops) to generate random numbers without duplicate…but the output turns out to be 10 repeating numbers, and I cannot figure out why. Here is my code: Answer You need to break out of the for loop if either of the conditions are met. This will make YOUR code work but @gonzo
A zero-indexed array given & An equilibrium index of this array [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month. Improve this question A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such
Getting only the first name in an array
I have an array list like this: ArrayList names = new ArrayList<>(); that stores people’s first and last names when they are entered in different textbooks. So when prompted to Joe Biden would be element number 1 then Barack Obama would be element number 2 in the array list. My question is that if it is possible to only get