title: Setting negative marks in an string to zero (java)
body: <p>Help, i cant figure this out, im new to java and never coded before this class im taking. the assignment is a code that deals with voting, basically the votes are given and i need to formalise them and make sure there are no errors such as negative votes. i dont thing i am suppose to change any of the code that was given including the constructor and the initialiser for each part. i need help with the part that says <code>//TODO 3</code></p>
  <pre><code>import java.util.*;
  
  public class VotingPaper {
      // the numbers marked on the paper
      private ArrayList&lt;Double&gt; marks;
      // precision required for matching doubles
      private double epsilon = 10e-4;
  
      /**
       * Constructor for objects of class VotingPaper.
       * s will be a sequence of doubles, separated by commas.
       * e.g. if s is &quot;1,22,-13,456&quot;, marks is set to &lt;1,22,-13,456&gt;.
       * s can also be a sigle value i.e. with no comma
       */
      public VotingPaper(String s) {
          marks = new ArrayList&lt;&gt;();
          for (String x : s.split(&quot;,&quot;))
              marks.add(Double.parseDouble(x));
      }
  
      /**
       * Returns the contents of the paper.
       */
      public ArrayList&lt;Double&gt; getMarks() {
          //TODO 1
          return marks;
      }
  
      /**
       * Checks if the paper has the correct number of marks i.e. one for each candidate.
       * If YES, ensures that the negative marks have been set to zero and
       * that marks are normalized to sum up to 1.0 and then returns true
       * If NO, it returns false
       */
      public boolean isFormal(int noOfCandidates) {
          // TODO 2
  
          if (noOfCandidates == marks.size()) {
              setNegativeMarksToZero();
          } else {
              return false;
          }
          return true;
      }
  
      /**
       * Sets all negative marks to zero
       */
   public void setNegativeMarksToZero()
  {
     //TODO 3
     double negativeMark = marks.get(1).doubleValue();
     for (Double val : marks) {
         System.out.println(val.doubleValue());
         if (val.doubleValue() &lt; 0.0) {
             val = Double((double)0.0);
             System.out.println(val.doubleValue());
         }
         else { 
             normalizeMarks();
         }
     }
  
  
  }
  
      private void normalizeMarks() {
      }
  }
  </code></pre>
  <p>This is the code. this is for a project and im stuck, i cant get the string to replace the negative numbers in the string with <code>0.0</code> but i can get it to set the negative value as <code>val.doubleValue()</code> and set that to <code>0.0</code>. thanks in advance for any help.</p>