title: How to get parseDouble to ignore "%" - Java
body: <p>I have the following code:</p>
  
  <pre><code>preferredCustomers[count]=new PreferredCustomer(fileData[1],fileData[2],Integer.parseInt(fileData[0]),Double.parseDouble(fileData[3]),(Double.parseDouble(fileData[4])));
  </code></pre>
  
  <p>which will be reading the line:</p>
  
  <p><strong>778234 Minnie Mouse 165.50 5%</strong> </p>
  
  <p>within a text document. My problem is that when I try to compile my program I get the following error:</p>
  
  <pre><code>run:
  java.lang.NumberFormatException: For input string: "5%"
      at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
      at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
      at java.lang.Double.parseDouble(Double.java:538)
      at customer.Main.main(Main.java:84)
  BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>
  
  <p>I cannot change how the text document is formatted, and the corresponding class has the following:</p>
  
  <pre><code>public class PreferredCustomer extends Customer {
  
     // Member variable discount
     double discountPercentage;
  
     // Default constructor
     public PreferredCustomer() {
         super();
     }
  
     // Parameterized overloaded constructor
     // Constructor chaining calling parent class constructor
     public PreferredCustomer(String first_name, String last_name, int guestID, double amountSpent, double discountPercentage) {
         super(first_name, last_name, guestID, amountSpent);
         //discountPercentage = discountPercentage.replace("%", "");
         this.discountPercentage = discountPercentage;
         // TODO Auto-generated constructor stub
     }
  
     // Getter and setter
     public double getDiscountPercentage() {
         return discountPercentage;
     }
  
     public void setDiscountPercentage(double discountPercentage) {
         this.discountPercentage = discountPercentage;
     }
  </code></pre>
  
  <p>How can I re-write the code to ignore this "%" sign so it will allow the program to compile? I am running in NetBeans, Thanks.</p>