Back to Examples
package edu.iuk.savings;

import java.util.Scanner;
import javax.swing.JOptionPane;

public class Savings {

  public static void main(String[] args) {

    //Jacob Morris
    double dollars;
    double rate;
    double total;

    Scanner cash = new Scanner(System.in);
    System.out.println(“Please enter amount of cash deposited into account. (digits only)”);
    //receive user cash deposit amount
    dollars= cash.nextDouble();

    Scanner percent = new Scanner(System.in);
    System.out.println(“Please enter the annual rate (in percent) of your account. (digits only)”);

    //receive user account rate
    rate = percent.nextDouble();
    rate = rate/100;
    //puts rate into a decimal

    total = Math.pow(1+ rate, 10)* dollars;

    //discovers total in the account
    total = (double)Math.round(total * 100) / 100;
    //rounds the total in the account to two decimal places
    JOptionPane.showMessageDialog(null, “The amount in this account after ten years of interest is $” + total);

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!