java program to find simple interest

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

showing results for - "java program to find simple interest"
Denzel
23 Jan 2020
1// Java program to find simple interest
2import java.util.Scanner;
3public class SimpleInterestJavaProgram
4{
5   public static void main(String[] args)
6   {
7      float principal, rate, time;
8      Scanner sc = new Scanner(System.in);
9      System.out.print("Enter principal amount : ");
10      principal = sc.nextFloat();
11      System.out.print("Please enter rate annually : ");
12      rate = sc.nextFloat();
13      System.out.print("Please enter time(in years) : ");
14      time = sc.nextFloat();
15      float simpleInterest;
16      simpleInterest = (principal * time * rate) / 100;
17      System.out.println("The Simple Interest is : " + simpleInterest);
18      sc.close();
19   }
20}
Pietro
05 Jan 2019
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}