DWQA Ask QuestionCategory: JavaJava_Q: Simple Interest and Compound Interest
admin Staff asked 7 years ago

Write a Program to calculate SImple Interest and compund interest. Ask Principal, interest and time from User

1 Answers
Kulkarni Arundhati answered 7 years ago
Start your code here
import java.util.Scanner;

public class Interest {

public static void main(String[] args) {
// TODO Auto-generated method stub
double ci, p, n, r,si;
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
System.out.println("Enter any amount to calculate the simple & compond interest: ");
p=scan.nextInt();
System.out.println("Enter any no of years: ");
n=scan.nextInt();
System.out.println("Enter the rate of interst: ");
r=scan.nextInt();
si=(p*n*r)/100;
ci=p*Math.pow(1+r/100,n)-p;
System.out. println(" Amount="+p );
System. out. println("N o. of years="+n);
System. out. println("Rate of interest="+r);
System.out.println("simple interest = " +si);
System.out.println("Compound Interest = " +ci);
}
}