জাভা প্রোগ্রামিং পর্ব-১৩



2.15** (Financial application: compound value) Suppose you save $100 each month into a savings account with the annual interest rate 5%. So, the monthly interest rate is After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507 and so on.
Write a program to display the account value after the sixth month. (In Exercise  4.30, you will use a loop to simplify the code and display the account value for any month.)

Code : File name-CompountValue.java
import java.util.*;
import javax.swing.*;
public class CompountValue {
    public static void main (String arg[]){
        double i, accountBecome, account=0;
        Scanner input =new Scanner(System.in);
        System.out.print("Enter amount: = ");
        double amount =input.nextDouble();
        System.out.print("Enter annual interest: = ");
        double annualInterest =input.nextDouble();
        System.out.print("Enter month: = ");
        double month =input.nextDouble();

        double monthlyInterest = annualInterest/1200;;

        for (i=1; i<=month; i++)
        {
           accountBecome = ((100+account)*(1+monthlyInterest));;
           account = accountBecome;
        }
        System.out.print("Account Become: = " +account);
        }
    }

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle