java programming

The following script will compute interest based on user entered variables (loan amount and interest rate) using java. Just copy and paste the below script into your preferred IDE (Integrated Development Environment) and run it.


	Programmer: Your Name
	Date:      June 17, 2018
	File Name:
	Purpose:   To create an app that gets a loan amount and interest 
                   rate from user, then formats output to reflect loan 
                   amount, interest as a percent, and interest amount.

//packages to import
import java.util.Scanner;
import java.text.NumberFormat;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class InterestCalculatorApp //class declaration
	public static void main(String args[])//this is main method header
	//welcome the user
	System.out.println("Welcome to the Interest Calculator App");
	System.out.println(); //print a blank line

	//construct a scanner object
	Scanner sc = new Scanner(;

	//perform conversions until choice is value other than "y" or "Y"
	String choice = "y";
	while (choice.equalsIgnoreCase("y"))

	//get input from the user
	System.out.print("Enter Loan Amount:\t");
	double loan = sc.nextDouble();
	NumberFormat currency = NumberFormat.getCurrencyInstance();
	String loanString = currency.format(loan);

	System.out.print("Enter Interest Rate:\t");
	double rate = sc.nextDouble();
	NumberFormat percent = NumberFormat.getPercentInstance();
	percent.setMaximumFractionDigits(3);//set max to three digits to the right of the decimal
	String rateString = percent.format(rate); 

	//calculate interest based on user loan and rate input
	double interest = loan * rate;
	BigDecimal intereString = new BigDecimal(Double.toString(interest));
	intereString = intereString.setScale(2, RoundingMode.HALF_UP);

	// display conversion result
	String message = "\nLoan Amount:\t" + loanString + "\nInterst Rate:\t" + rateString + "\nInterest:\t" + currency.format(intereString);

	//see if user wants to continue
	System.out.print("\nContinue? (y/n):\t");
	choice =;

		}//end while loop
	}//end main()
} //end class GradeConverter