Write a java programme to calculate simple interests and compound interest.
Answers
Answer:
Java Program to Calculate simple interest and compound interest
In this example, we will learn to calculate the simple interest and compound interest in Java.
To understand this example, you should have the knowledge of the following Java programming topics:
Java Scanner Class
Java Operators
Example 1: Calculate Simple Interest in Java
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// create an object of Scanner class
Scanner input = new Scanner(System.in);
// take input from users
System.out.print("Enter the principal: ");
double principal = input.nextDouble();
System.out.print("Enter the rate: ");
double rate = input.nextDouble();
rate = rate/100;
System.out.print("Enter the time: ");
double time = input.nextDouble();
double interest = (principal * time * rate) / 100;
System.out.println("Principal: " + principal);
System.out.println("Interest Rate: " + rate);
System.out.println("Time Duration: " + time);
System.out.println("Simple Interest: " + interest);
input.close();
}
}
Answer:
yes upper answer is right