Answers for "Java program to calculate compound interest"

1

Java program to find simple interest

// Java program to find simple interest
import java.util.Scanner;
public class SimpleInterestJavaProgram
{
   public static void main(String[] args)
   {
      float principal, rate, time;
      Scanner sc = new Scanner(System.in);
      System.out.print("Enter principal amount : ");
      principal = sc.nextFloat();
      System.out.print("Please enter rate annually : ");
      rate = sc.nextFloat();
      System.out.print("Please enter time(in years) : ");
      time = sc.nextFloat();
      float simpleInterest;
      simpleInterest = (principal * time * rate) / 100;
      System.out.println("The Simple Interest is : " + simpleInterest);
      sc.close();
   }
}
Posted by: Guest on December-10-2020
1

Java program to calculate compound interest

// Java program to calculate compound interest
public class CompoundInterestDemo 
{
   public void calculateCompound(int p, int t, double r, int n) 
   {
      double number = p * Math.pow(1 + (r / n), n * t);
      double interest = number - p;
      System.out.println("Compound interest after " + t + " years: " + interest);
      System.out.println("Money after " + t + " years: " + number);
   }
   public static void main(String[] args) 
   {
      CompoundInterestDemo obj = new CompoundInterestDemo();
      obj.calculateCompound(200000, 6, .06, 12);
   }
}
Posted by: Guest on February-19-2021

Code answers related to "Java program to calculate compound interest"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language