Question: JAVA PROGRAMMING QUESTION: I recently had an interview for an entry-level Java Developer position. I did not end up getting the position, to which I
JAVA PROGRAMMING QUESTION:
I recently had an interview for an entry-level Java Developer position. I did not end up getting the position, to which I attribute, in large part, to my inability to answer a particular programming question. I am curious if anyone might be able to assist me in solving the problem that was asked to me, so that I may be prepared for similar questions in future interviews.
The question was:
There are X amount of furniture stores in a state, each within a district. Each store is assigned a unique 6-digit store number, with the first four digits denoting the specific region/district and the appending 2-digits denoting the specific store within the district (e.g., 100134; 100234; 100387; 100523; 100113; 100223; 100255; 100522).
The interviewer then stated that there was a hypothetical flat-file that contained a given days sales for each store and my task was to quickly write a Java program using HashMap to calculate and display the total sales for the given day PER DISTRICT.
For some reason, I could not figure out how to do this. I proposed a Switch Statement or an If-Else Statement; however, I was told that this would be inefficient and that the algorithm would have to account for new stores being added to any given district, along with the possible addition of new districts at any given time.
I was then instructed that my answer had to include a Substring and HashMap. I am still unsure as to what type of answer my interviewer might have been looking for? Any help would be greatly appreciated!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
