Im doing a Loan Calculator for class. I'm nearly done but the only thing missing is how to round INTEREST_RATE instead of $298.95833333333337 i would like to get $298.96. But i don't know how.
Enter your old Principle =
25000
Enter your current payment =
450
Previous Balance: $25000.0
Payment: $450.0
Interest Paid: $151.04166666666666
Principle Paid: $298.95833333333337
New Principal: $24701.041666666668
import java.util.Scanner;
public class LoanCalculator {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/**
* Declaration Section
*
*/
Scanner keyboard = new Scanner(System.in);
double INTEREST_RATE;
double currentPayment;
double oldPrincipal;
double interestPaid;
double principalPaid;
double newPrincipal;
/**
* Process Section
*
*/
System.out.println("Enter your old Principle = ");
oldPrincipal = keyboard.nextDouble();
System.out.println("Enter your current payment = ");
currentPayment = keyboard.nextDouble();
INTEREST_RATE = 7.25 / 100.0; //fix this
interestPaid = oldPrincipal * INTEREST_RATE / 12;
principalPaid = currentPayment - interestPaid;
newPrincipal = oldPrincipal - principalPaid;
/**
* Output Section
*
* */
System.out.println("Previous Balance: " + "$"+ oldPrincipal);
System.out.println("Payment: " + "$"+ currentPayment);
System.out.println("Interest Paid: " + "$"+ interestPaid);
System.out.println("Principle Paid: " + "$"+ principalPaid);
System.out.println("New Principal: " + "$"+ newPrincipal);
}//Main()
}//LoanCalculator