Objective The application prompts the user to enter a loan amount and an interest rate. The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. The application prompts the user to continue. Directions: 1. Create a new application and name it LastName_Assignment02. 2. Create the Scanner object. 3. Get the loan information from the end user by using the System class. 4. Calculate the interest amount by using the BigDecimal class to make sure that all calculations are accurate. 5. Format the interest rate, interest amount and loan amount and interest by using the NumberFormat abstract base class. It should round the interest that’s calculated to two decimal places, rounding up if the third decimal place is five or greater. The value for the formatted interest rate should allow for up to 3 decimal places. 6. Display the results by using the System class. 7. Assume that the user will enter valid double values for the loan amount and interest rate. 8. The application should continue only if the user enters “y” or “Y” to continue. https://online.national.edu/shared/UnderGrad_Resources/Course%20Images/CI3680/LP2assign_image1.png

Below is the java program with comments on what a line do
import java.util.Scanner;
import java.math.*;
import java.text.*;
import java.util.Locale;
//You can name the class as per your requirement
public class YourClass{
public static void main(String []args){
double amount, rate;
Scanner s = new Scanner(System.in);
//To get the locale and we want currency to printed in $ hence “US”
Locale US = new Locale(“en”,”US”);
//To format loan amount
NumberFormat amountFormat = NumberFormat.getCurrencyInstance(Locale.US);
//To format percentage upto three decimal places
NumberFormat percent = NumberFormat.getPercentInstance();
percent.setMaximumFractionDigits(3);
//To format interest amount upto two decimal places
NumberFormat interestFormat = NumberFormat.getCurrencyInstance(Locale.US);
interestFormat.setMaximumFractionDigits(2);
String option = “y”;
while(option.equalsIgnoreCase(“y”))
{
System.out.println(“Enter loan amount”);
amount = s.nextDouble();
System.out.println(“Enter the interest rate”);
rate = s.nextDouble();
//BigDecimal methods to calculate interest
BigDecimal decRate = new BigDecimal(Double.toString(rate));
BigDecimal decAmount = new BigDecimal(Double.toString(amount));
BigDecimal decinterest = decRate.multiply(decAmount);
//rounding off the interest
decinterest = decinterest.setScale(2, RoundingMode.HALF_UP);
System.out.println(“Loan Amount: “+” “+amountFormat.format(decAmount));
System.out.println(“Interest Rate: “+” “+ percent.format(decRate));
System.out.println(“Interest: “+ ” “+ interestFormat.format(decinterest));
System.out.println(“Continue? y/n: “);
option = s.next();
System.out.println();
}
}
}
Output:
https://d2vlcm61l7u1fs.cloudfront.net/media%2F2c3%2F2c30b7cd-dadb-437b-92ce-865f8b1f445b%2Fphp3Ex8tD.png
 
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"