HI All, I been working on this for days and cant seem to get my head around it. The sceanrio is to convert from a currency to british pounds working out commision rates etc.The examples of inputs I have been given are:

Currency to convert from: CNY
Rate of exchange to Sterling pence: 0.1377
Commission rate: 2.5
Amount to exchange: 11428.55
Amount to exchange: 198.22


This is the result I am getting is

Currency to convert from: cny
Rate of exchange to Sterling pence: 0.1377
commision Rate: 2.5
Amount to exchange: 11428.55
11428.55 cny is 829.960058097313 pence
Commission is 5 pounds 0 pence
Actual sterling amount is 3 pounds 29 pence
11428.55 cny is 829.960058097313; commission 500.0 GBP; payout329.960058097313


when it should be

11428.55 CNY is 829.96 GBP; commission 20.74 GBP; payout 809.22 GBP

Hope someone one can help this is the code I have provided below

public class ProcessCurrency {

static final int min_comm = 500;

public static void main(String[] argv) {


double commRate, foreignAmount, exchangeRate, penceAmount,actPayOut, actPoundPence;
String currencyToConverFrom;
double comm = 0;
double commPoundPence = 0;
int trans=0;
double totForeign=0, totSterling=0, totHandouts=0, totComission=0, avgHand=0,forSter=0;

System.out.print("Currency to convert from: ");
currencyToConverFrom = UserInput.readString();

System.out.print("Rate of exchange to Sterling pence: ");
exchangeRate = UserInput.readDouble();

System.out.print("commision Rate: ");
commRate = UserInput.readDouble();

System.out.print("Amount to exchange: ");
foreignAmount = UserInput.readDouble();




while (foreignAmount != 0){
penceAmount = foreignAmount / exchangeRate / 100;

System.out.println(foreignAmount + " " + currencyToConverFrom + " is "+ penceAmount + " pence");



if (penceAmount < min_comm)
System.out.println("Amount too small");
else {
comm = penceAmount * (commRate/100);
trans++;
if (comm < min_comm){
comm = 500;
}// PAmt<min100);

System.out.println("Commission is "+(int)(comm/100)+" pounds "+(int)(comm%100)+" pence ");

actPayOut = penceAmount - comm;

actPoundPence = actPayOut/100;

System.out.println("Actual sterling amount is "+(int)actPoundPence+" pounds "+(int)(actPayOut%100)+" pence");

totForeign+=foreignAmount;
totSterling+=penceAmount;
totHandouts+=actPayOut;
totComission+=comm;
avgHand = totHandouts/trans;
forSter = totForeign/totHandouts;

System.out.println(foreignAmount + " " + currencyToConverFrom +" is "+ penceAmount +"; commission "+comm+" GBP; payout" + actPayOut + " GBP");
}//end else

System.out.print("Amount to exchange: ");
foreignAmount = UserInput.readDouble();
}//end while


System.out.println("Transactions " + trans);
System.out.println("Total "+ currencyToConverFrom +" received " + totForeign);
System.out.println("Total sterling value " + totSterling);
System.out.println("Total handouts " + totHandouts);
System.out.println("Total Commission " + totComission);
System.out.println("Average handout " + avgHand);
System.out.println(currencyToConverFrom +" per pound " + forSter);







}

}