import java.text.*;

public class CalcClient
{
	static javacalc jc;
	public static void main(String args[])
	{
		if (args.length < 2)
			System.out.println("CalcClient <interest rate> <amount> [amount]...");
		else
		{
			jc = new javacalc();
			try {
				double rate = Double.valueOf(args[0]).doubleValue();
				DecimalFormat f = new DecimalFormat("00.00");
				StringBuffer rateBuffer = f.format(rate, new StringBuffer(), new FieldPosition(DecimalFormat.FRACTION_FIELD));

				jc.setInterestRate(rateBuffer.toString());
			} catch (Exception e) {
				System.out.println(e.toString());
			}

			for (int i = 0; i < args.length - 1; i++)
			{
				double d = Double.valueOf(args[i+1]).doubleValue();
				if (d < 0)
					d = -d;
				System.out.println ("For amount " + d + " at rate " + args[0] + "%:");
				showAfterInterest(d, 1);
				showAfterInterest(d, 5);
				showAfterInterest(d, 10);
				showAfterInterest(d, 20);
				System.out.println ("----");
			}
		}
	}

	public static void showAfterInterest(double amount, int years)
	{
		try {
			String total = jc.calcSimpleInterest(amount, years);
			System.out.println("With simple interest after " + years + " year(s) = " + total);
			total = jc.calcCompoundInterest(amount, years);
			System.out.println("With compound interest after " + years + " year(s) = " + total);
		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}