import java.util.*; public class ExchangeCanadianRate{ private double[] us2caRates; private double amount; public ExchangeCanadianRate(double[] rates, float amount){ this.amount = amount; this.us2caRates = rates; } public static void main(String[] args){ String input = "3\n1.0500\n0.9300\n0.9900\n2\n1.0500\n1.1000\n3\n.9\n1.1\n0.9\n0"; Scanner sf = new Scanner( input ); double[] ca_us_rate = null; while(sf.hasNext()){ int n = sf.nextInt(); if(n == 0) break; ca_us_rate = new double[n]; for(int i=0;i solutions = new ArrayList(); List sstr = new ArrayList(); for(int i=0;i> 1; if(rmd == 1) { // handle the case from us->ca or ca->us if(!inCanadian) rate = this.us2caRates[index]; else rate = 1f/this.us2caRates[index]; money = money * rate ; money -= money * 0.03; inCanadian = !inCanadian; lastIndex = index; sb.append(1); }else sb.append(0); } if(!inCanadian){ money = money * this.us2caRates[lastIndex]; } solutions.add(money); sstr.add(sb.toString()); } format(solutions, sstr); } public void format(List lst, List strl){ double max = lst.get(0); for(int i=0;i max) max = a; } for(int i=0;i" +lst.get(i) + (a == max ? " ===>Best Choice" : "")); } } }