title: Pens percentage of unused
body: <p>The statement says:</p>
  
  <p>A pen manufacturer has automated quality control of its products. When a
  pen meets the minimum requirements, the unit in charge of quality control writes the letter 'S', otherwise writes 'N' and when finalize writes 'F'. Consider that after each
  these characters of the device introduces a "intro / enter." Write a program that calculates the
  percentage of pens that have not met the minimum requirements of manufacture. Supposed
  the device writes the data correctly. (Boligrafos.java).</p>
  
  <p>I put this code:</p>
  
  <pre><code>import java.util.Scanner;
  
    public class Boligrafs {
  
      public static void main ( String [] args ) {
  
      Scanner sc = new Scanner (System.in);
  
      String estat;
      int contador1 = 0, contador2 = 0;
      float percentatge;
  
      System.out.println("Introdueix un estat del boligraf");
      estat = sc.next();
  
      while (estat == "S" || estat == "N") {
        if (estat == "S"){
          System.out.println("Introdueix un estat del boligraf");
          estat = sc.next();
        }
        else if (estat == "N"){
          System.out.println("Introdueix un estat del boligraf");
          estat = sc.next();
          contador1 = contador1 + 1;
        }
      contador2 = contador2 + 1;
      }
      if (estat == "F") {
        System.out.println("Has finalitzat");
      }
  
      percentatge = 100 * contador1 / contador2;
      System.out.println("El percentatge es:"+percentatge+"%");
  
    }
  }
  </code></pre>
  
  <p>I can't understand the error because i think my program is correct: </p>
  
  <p>Exception in thread "main" java.lang.ArithmeticException: / by zero
          at Boligrafs.main(Boligrafs.java:32)</p>