-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleInterestCalculator.java
More file actions
34 lines (25 loc) · 1.19 KB
/
SimpleInterestCalculator.java
File metadata and controls
34 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//this is a small project in java trying to create a simple interest calculator
import java.util.Scanner;
public class SimpleInterestCalculator {
//create a scanner object
public static void main(String[] args) {
//create principal amount
Scanner myobject = new Scanner(System.in);
//create principalvalue
System.out.println("Enter the principal value: ");
double PrincipalValue = myobject.nextDouble();
System.out.println("The principal amount is " + PrincipalValue + "$");
//create rate
System.out.println("Enter the rate: ");
int Rate = myobject.nextInt();
System.out.println("The rate is " + Rate + " %");
//calculate simple interest
System.out.println("Enter the time: ");
double Time = myobject.nextDouble();
System.out.println("The time is " + Time + " years");
double Interest = (PrincipalValue * Rate * Time) / 100;
System.out.println("The interest is " + Interest + "$");
double TotalAmount = (PrincipalValue + Interest);
System.out.println("The total amount is " + TotalAmount + "$");
}
}