/** * Simulations of various banking activities. * * @author Samuel A. Rebelsky * @author ... * @version 1.0 */ public class Bank { /** The default interest rate */ public static double default_rate = (double) 0.03; /** Compute the present value of an investiment. Permits you to specify investment, annual rate and number of years. Assumes that interest is compounded annually. */ public static double presentValue(double investment, double rate, int years) { // Not yet implemented return (double) 1.0; } // presentValue /** Test our various methods. */ public static void main(String[] args) { // Determine the periods we'll be using int[] periods = { 0, 1, 10, 100, 1000, 10000 }; // The present value double pv; // For timing long before; long after; // Print out the results for (int i = 0; i < periods.length; ++i) { before = System.currentTimeMillis(); pv = presentValue((double) 5.0, default_rate, periods[i]); after = System.currentTimeMillis(); System.out.println("$5 after " + periods[i] + " years is " + pv); System.out.println("That computation took " + (after-before) + " milliseconds."); } // for } // main } // Bank