title: How would I store values in an array in java?
body: <p>I want to store non &quot;h&quot; values in an array. So to give you a background, I need to make a basic cash register that accepts 5 items in an array with a price on them. Nevertheless, some items will have HST(tax) included with them. To know which items have tax and which don't. The user will press h or H before or after entering the dollar amount. I have stored the values with the HST in an array, but how would I store the non-HST values?</p>
  <p>Sample input:</p>
  <pre><code>4.565H
  H2.3435
  4.565h
  5.234
  5.6576h
  </code></pre>
  <p>Sample Output:</p>
  <pre><code>HST Values:
  4.565
  2.3435
  4.565
  5.6576
  
  Non-HST Values
  5.234
  </code></pre>
  <hr />
  <p>My Code:</p>
  <pre><code>import java.util.Scanner;
  
  class Main {
      public static void main(String[] args) {
          // Create scanner object and set scanner variables
          Scanner inp = new Scanner(System.in);
          System.out.println(&quot;Press any key to start&quot;);
          String key = inp.nextLine();
          System.out.println(&quot;\nEnter the amount of each item&quot;);
          System.out.println(&quot;Up to 5 inputs are allowed!\n&quot;);
  
          // Initialize counter and index variables to use it in the while loop
          int counter = 0;
          int index = 0;
   
          // Create a double array variable, and set the limit to 5
          double[] numbers = new double[5];
  
          // Create a boolean variable to use it in the while loop
          boolean go = true;
  
          while (go) {           
              String value = inp.nextLine();      
              value = value.toLowerCase();
    
              // Set the index value to &quot;h&quot; or &quot;H&quot;
              int indexOfh = value.indexOf('h');
  
              boolean containsh = (indexOfh == 0 || indexOfh == value.length() - 1);
              
              if (containsh) { //Validate h at beginning or end
                  numbers[index] = Double.parseDouble(value.replace(&quot;h&quot;, &quot;&quot;));
                  index++;
                  System.out.println(&quot;HST will be taken account for this value&quot;);
              }
  
              counter++;
              if (counter == 5) {
                  go = false;
              }
          }
  
          System.out.println(&quot;HST Values:&quot;);
          for (int i = 0; i &lt; numbers.length; i++) {
              System.out.println(numbers[i]);
          }
      }
  }
  </code></pre>