Call
(317)643-0663
for consultation
Experience Programming
.
Home
Pricing
About
Contact
Java Example
Savings Account Interest Example
.
Back to Examples
package edu.iuk.Interest;
//imports
import javax.swing.JOptionPane;
public class Interest {
public static void main(String[] args) {
// Jacob Morris
// declare variables
int savingsAmount;
double currentSavings = 0.0;
// get user input
savingsAmount = Integer
.parseInt(JOptionPane.showInputDialog(“Please enter the amount you are going to save (monthly)”));
for (int i = 0; i < 6; i++) {
// multiply by monthly interest rate
currentSavings = (currentSavings + savingsAmount) * 1.00417;
}
// rounds account to two decimal places
currentSavings = (double) Math.round(currentSavings * 100) / 100;
// output user’s account total after six months
System.out.println(“The account total after six months is $” + currentSavings);
}
}
Back to Examples
Startup Discount
Small Business?
Contact us for an
Enormous
Discount!
Contact Us Today!