Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Example Output Welcome to the Interest Calculator Enter loan amount: 520000 Enter interest rate: . 05375 Loan amount: $520,000.00 Interest rate: 5.375% Interest: $27,950.00 Would

Example Output

Welcome to the Interest Calculator

Enter loan amount: 520000

Enter interest rate: . 05375

Loan amount: $520,000.00

Interest rate: 5.375%

Interest: $27,950.00

Would you like to enter another loan amount? (y/n): y

Enter loan amount: 4944.5

Enter interest rate: .01

Loan amount: $4,944.50

Interest rate : 1%

Interest : $49.45

Would you like to enter another loan amount? (y/n): n

Total loan = $524944.50

Total interest = $27999.45

Thank you.

//Loan.java Program

public class Loan { //create the private double attributes : loanAmt, interestRate, interestAmount, totalAmt //create a default construction to initialize all of the attributes //create a setter for each attribute //create a getter for each attribute //complete the calculateLoan method public void calculateLoan() { System.out.println("loan amount : " + this.loanAmt); System.out.println("interest rate: " + (/*convert the decimal to a whole number */ + "%"); System.out.println("interest : " + (/*calculate the interest rate for the loanAmt */ ) ) ; //calculate the cumlative interestAmount //compute the cumlative loanAmt } public static void main(String[] args) { String flag=""; int counter=0; double loanvalue=0.0; double interest = 0.0; System.out.println("Welcome to the Interest Calculator"); //create a Loan called obj Scanner keyboard = new Scanner(System.in); do { System.out.print("Enter loan amount : "); loanvalue = keyboard.nextDouble(); System.out.print("Enter interest rate: "); interest = keyboard.nextDouble(); //use the setter to set the loanAmt with the loanvalue for the Loan obj //use the setter to set the interestRate with the interest for the Loan obj //call the calculateLoan method for the Loan obj System.out.print(" Would you like to enter another loan amount? (y/n):"); Scanner input = new Scanner(System.in); flag = input.nextLine();

if (++counter >=3) flag="n"; } while ( flag.equalsIgnoreCase("Y")); System.out.println(" Total loan : " + /*get the total Amt for the Loan obj */ ); System.out.println("Total interest : " + /*get the interest Amount for the Loan obj */ ); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

Calculate the derivative indicated. f""(-3), f(x) = 12 X x3

Answered: 1 week ago

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago