/* IntCalc2.java David G. Klick September 7, 2007 CIS 111 Demonstration program which uses input, processing, and output - redone with methods (modules). */ public class IntCalc2 extends CIS111App { // Global variables are not ideal program design, but // they serve to illustrate some concepts in this program. private static double prin; private static double interest; private static int years; private static int periods; public static void main(String[] args) { // declare variables double amt; getInput(); amt = calcAmt(prin, interest, years, periods); displayAmt(amt); } private static void getInput() { // get principal, interest, years, periods prin = getDouble("Enter the principal: "); interest = getDouble("Enter the yearly interest: "); years = getInt("Enter the number of years: "); periods = getInt("Enter the number of periods per year: "); } private static double calcAmt(double pr, double interest, int yr, int per) { // calculate future value double x = (1 + (interest / 100) / per); double y = (yr * per); double n = pr * Math.pow(x, y); return n; } private static void displayAmt(double total) { // display future value printf("The future value is %.2f\n", total); } }