Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would just add upon the issues that I find out in your code. </p> <p>(1). First issue that I found is in the function <code>importFile</code>.</p> <pre><code> for (int i = 0; i &lt; NUM_STATES; i++) { array[i] = scanner.nextLine(); } </code></pre> <p>This loop looks erroneous to me. You are trying to scan a line for 50 times from a file and each line you want it to store in an index position of string. This is absurd. Also, are you really sure that you have to run the loop 50 times always? (This too looks erroneous to me).</p> <p>So, Of what I perceive, I think that you meant to read 50 characters from file 1 and put it into String array of size 50, which means you have to read one character at a time.</p> <p>So my suggestions to clear this issue would be : </p> <pre><code>(a). Read one character at a time. (b). If you are not sure about the size of each file, iterate through it till the EOF. </code></pre> <p>(2). Second issue I find in <code>createFile</code> method. </p> <p>You are creating a new file and inserting the first character from all the files. Then the second . Then the third... Till 50th character. </p> <p>What if a respective file does not have any data till 50th character. This will feed in erroneous data in your resultant file. This may not lead to a compile time exception but may lead to a run time exception that is undesirable.</p> <p>(3). In the <code>main</code> method:</p> <pre><code> for (int x = 0; x &lt; NUM_STATES; x++) { **createFile(stateNames, nicknames, capital, flowers, populations);** char getWantsToContinue = 'y'; while (getWantsToContinue == 'y' || getWantsToContinue == 'Y') { System.out.println(stateNames); int index = askState(stateNames); String unformattedPopulation = populations[index]; String formattedPopulation = formatPopulation(unformattedPopulation); outPut(stateNames,nicknames, capital, flowers, formattedPopulation,index); } </code></pre> <p>This means that <code>createFile</code> method is called for 50 times. Which always creates the same "state_data.txt" file for 50 time ?? (What is this for?)</p> <p>Looking for other issues. Meanwhile, start working on correcting it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload