Monday, September 13, 2021

This class implements a simple program that will compute the amount of interest that is earned on an investment over a period of one year. The initial amount of the investment and the interest rate are input by the user. The value of the investment at the end of the year is output. The rate must be input as a decimal, not a percentage (for example, 0.05 rather than 5). with user input


/**
* This class implements a simple program that will compute
* the amount of interest that is earned on an investment over
* a period of one year. The initial amount of the investment
* and the interest rate are input by the user. The value of
* the investment at the end of the year is output. The
* rate must be input as a decimal, not a percentage (for
* example, 0.05 rather than 5).
*/

import java.util.Scanner;
public class BSIT
{
public static void main(String[] args)
{
Scanner readme = new Scanner(System.in);

double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.

System.out.println("Enter the initial investment: ");
principal = readme.nextInt();

System.out.println("Enter the annual interest rate: ");
rate = readme.nextInt();

interest = principal * rate; // Compute this year's interest.
principal = principal + interest; // Add it to principal.

System.out.println("The value of the investment after one year is $");
System.out.println(principal);


}

}
































No comments:

Post a Comment

Contact Us

Contact Form

Name

Email *

Message *