title: Java: Read integers from an existing text file and output to another file
body: <p><strong>BAR CHART</strong></p>
  
  <p>Write a Java program that reads today's sales figures (integers) for five stores from an existing text file called sales.txt and output to a new file called storeReport.txt </p>
  
  <p>The program should display a bar chart comparing each store's sales.  Create each bar in the bar chart by displaying a row of asterisks.  Each asterisk should represent $100 of sales.</p>
  
  <p><strong>Below are the integers to be read from sales.txt:</strong></p>
  
  <pre><code>1000
  1200
  1800
  800
  1900
  </code></pre>
  
  <p><strong>The output file (storeReport.txt) should look like this:</strong></p>
  
  <pre><code>Store 1: **********
  Store 2: ************
  Store 3: ******************
  Store 4: ********
  Store 5: *******************
  </code></pre>
  
  <p>Keep in mind, I'm only in Chapter 5: Intro to Loops and Files, of Intro to Java.  The answer must be <em>very simplistic</em>. We haven't gotten to the following in my text yet, so please refrain from using them:  int[ ],  bufferedWriter, fstream, .length,  out.print .....etc, etc</p>
  
  <p>Thus, I must use the simplest of code such as:</p>
  
  <pre><code>Scanner inputFile = new Scanner (file)
  File inputFile = new File (sales.text)
  PrintWriter outputFile = new PrintWriter (storeReport.txt)
  </code></pre>
  
  <p>We may use for loops, while loops, and nested loops.</p>
  
  <p>Below is the code that I've written thus far.  I'm getting compile errors.  Please help!!  Thanks!</p>
  
  <pre><code>import java.util.Scanner;
  
  import java.io.*;
  
  public class BarChart
  {
      public static void main(String[] args) throws IOException
  
     {   
  
          int store1,store2,store3,store4,store5;
          int bar1,bar2,bar3,bar4,bar5;
  
          Scanner inputFile = new Scanner(System.in); 
  
          File inputFile = new File("sales.txt");
  
  
          File outputFile = new File("storeReport.txt");  
  
          PrintWriter outputFile = new PrintWriter("storeReport.txt");
  
  
          outputFile.println("SALES BAR CHART\n");            
  
          bar1 = store1/100;
          outputFile.println("store 1 : ");
          for(int i = 1; i &lt;= bar1; i++)
              outputFile.println("*");
  
          bar2 = store2/100;
          outputFile.println("\nStore 2 : ");
          for(int i = 1; i &lt;= bar2; i++)
              outputFile.println("*");
  
          bar3 = store3/100;
          outputFile.println("\nStore 3 : ");
          for(int i = 1; i &lt;= bar3; i++)
              outputFile.println("*");
  
          bar4 = store4/100;
          outputFile.println("\nStore 4 : ");
          for(int i = 1; i &lt;= bar4; i++)
              outputFile.println("*");
  
          bar5 = store5/100;
          outputFile.println("\nStore 5 : ");
          for(int i = 1; i &lt;= bar5; i++)
              outputFile.println("*");
  
          inputFile.close();
  
          outputFile.close();     
  
          System.out.println("Data written to the storeReport.txt");
          System.exit(0);
  
      }
  }
  </code></pre>