title: Why does this program only output 1 pence and 2 pence 50% of the time?
body: <pre><code>public class Bankteller2 {
  public static void main(String args[]){
      //declares and initialise variables
      double Sterling = 188.23;
      String indent = "";
      double Hundreds, Fifties, Twenties, Tens, Fives, Ones, fifty_pence, twenty_pence, ten_pence, five_pence, two_pence, one_pence;
  
      //converts sterling amount into a working number of pounds and pence
      Ones =  Sterling;
  
  
      Hundreds =  Ones / 100;
      Ones =  Ones % 100;
      one_pence = Ones % 1;
  
      Fifties =  Ones / 50;
      Ones =  Ones % 50;
      one_pence = Ones % 1;
  
  
      Twenties =  Ones/20;
      Ones =  Ones % 20;
      one_pence = Ones % 1;
  
  
      Tens =  Ones / 10;
      Ones =  Ones % 10;
      one_pence = Ones % 1;
  
  
      Fives =  Ones / 5;
      Ones =  Ones % 5; 
      one_pence = (Ones % 1) *100;
  
  
      fifty_pence = one_pence / 50;
      one_pence =  one_pence % 50;
  
  
      twenty_pence = one_pence / 20;
      one_pence =  one_pence % 20;
  
  
      ten_pence =  one_pence / 10;
      one_pence =  one_pence % 10;
  
  
      five_pence =  one_pence / 5;
      one_pence =  one_pence % 5;
  
  
      two_pence =  one_pence / 2;
      one_pence =  one_pence % 2;
  
  
      //output results
      System.out.println("The notes are :");
      System.out.println();
      System.out.println(indent + "Hundreds :"+(Math.floor( Hundreds)));
      System.out.println(indent + "Fifties :"+(Math.floor( Fifties)));
      System.out.println(indent + "Twenties :"+(Math.floor( Twenties)));
      System.out.println(indent +"Tens :" +(Math.floor( Tens)));
      System.out.println(indent + "Fives :"+(Math.floor( Fives)));
      System.out.println(indent +"One pound coins :"+(Math.floor( Ones)));
      System.out.println(indent +"Fifty pence :"+(Math.floor( fifty_pence)));
      System.out.println(indent +"Twenty pence :"+(Math.floor( twenty_pence)));
      System.out.println(indent +"Ten pence :"+(Math.floor( ten_pence)));
      System.out.println(indent +"Five pence :"+(Math.floor( five_pence)));
      System.out.println(indent +"Two pence :"+(Math.floor( two_pence)));
      System.out.println(indent +"One pence :"+(Math.floor( one_pence)));
      System.out.println();
      System.out.println("Total: "+ Sterling + " ");
  } }
  </code></pre>
  
  <p>the output i get is as following:</p>
  
  <pre><code>The notes are :
  
  Hundreds :1.0
  Fifties :1.0
  Twenties :1.0
  Tens :1.0
  Fives :1.0
  One pound coins :3.0
  Fifty pence :0.0
  Twenty pence :1.0
  Ten pence :0.0
  Five pence :0.0
  Two pence :1.0
  One pence :0.0
  
  Total: 188.23 
  </code></pre>
  
  <p>however there should be 1 in the One pence output.
  Similar things happen when other "pence" values are inputted below 10 and above 50.</p>