simple interest in java

Solutions on MaxInterview for simple interest in java by the best coders in the world

showing results for - "simple interest in java"
Isabella
20 Nov 2020
1import java.util.Scanner;
2
3public class Main {
4
5    public static void main(String[] args) {
6
7        // simple interest
8
9        Scanner scanner = new Scanner(System.in);
10
11        System.out.print("Enter principal amount: ");
12        float principal = scanner.nextFloat();
13
14        System.out.print("Enter time in years: ");
15        float time = scanner.nextFloat();
16
17        System.out.print("Enter rate: ");
18        float rate = scanner.nextFloat();
19
20        float simpleInterest = (principal * time * rate) / 100;
21
22        System.out.println("The simple interest is " + simpleInterest);
23    }
24}