Computer Science, asked by PriyamPathak, 1 year ago

write a program to find compond interest in bluej

Answers

Answered by Anant67
0
How to write a Java program to calculate compound interest? Here we share the code in five different formats to find compound interest program. Using standard values, using recursion, using command line arguments, using while loop, for loop , and using function method etc.

We can even write the following java code to find compound interest in more than 10+ ways as a beginner we share only the basic versions here. If you have any doubts related to the following code, then do leave a a comment here. Here is the complete list of beginners programs and java interview programs. Also check out the core java interview questions.


PriyamPathak: write a program
Answered by Spandbln
1

Answer:

//program for both simple and compound interest

//I have also used switch case here

import java.util.Scanner;

public class aXe12

{

   public static void main()

   {

       Scanner axe=new Scanner(System.in);

       System.out.println("Enter Principal Amount");

       int p=axe.nextInt();

       System.out.println("Enter Rate");

       int r=axe.nextInt();

       System.out.println("Enter Time");

       int t=axe.nextInt();

       System.out.println("1.For Simple Interest");

       System.out.println("2.For Compound Interest");

       System.out.println("Now Enter Your choice");

       int choice=axe.nextInt();

       switch(choice)

       {

           case 1:

           double si=((p*r*t)/100.0);

           System.out.println("The Simple Interest is: "+si);

           break;

           case 2:

           double ci=p*(Math.pow(1+r/100.0,t));

           System.out.println("The Simple Interest is: "+ci);

           break;

           default:

           System.out.println("Invalid Button");

           break;

       }

   }

}

Explanation:

Similar questions