/*Calculate Simple Interest In Java */
● Open notepad and add the code.
● Save the file as SimpleInterest.java.
● When the program is run, the following output is displayed:
>java SimpleInterest
Enter principal amount:123
Enter rate:12
Enter time (in years):1
Simple Interest is:14.76
//programming789.blogspot.com
import java.util.Scanner;
public class SimpleInterest {
public static void main(String args[]) {
float p, r, si;
int t;
Scanner sc = new Scanner(System.in);
System.out.print("Enter principal amount:");
p = sc.nextFloat();
System.out.print("Enter rate:");
r = sc.nextFloat();
System.out.print("Enter time (in years):");
t = sc.nextInt();
si = (p * r * t) / 100;
System.out.println("Simple Interest is:" + si);
}
}
import java.util.Scanner;
public class SimpleInterest {
public static void main(String args[]) {
float p, r, si;
int t;
Scanner sc = new Scanner(System.in);
System.out.print("Enter principal amount:");
p = sc.nextFloat();
System.out.print("Enter rate:");
r = sc.nextFloat();
System.out.print("Enter time (in years):");
t = sc.nextInt();
si = (p * r * t) / 100;
System.out.println("Simple Interest is:" + si);
}
}
● Open notepad and add the code.
● Save the file as SimpleInterest.java.
● When the program is run, the following output is displayed:
>java SimpleInterest
Enter principal amount:123
Enter rate:12
Enter time (in years):1
Simple Interest is:14.76