Today I am going to use Java to make a command line application called Simple Interest Calculator with working example. Code was written by my Student Abhijit [doing Bsc (Computer science)].
Simple Interest Formula
SI = PRT/100N
where P= Principle, R=Rate (Annual) ,T= Time Period, N= Frequency of calculation in one year.
Screen shot
Simple Interest Java Code :
[java]
import java.util.Scanner;
/*
* By Abhijit Prasad (Student)
* Simple Interest Calculator
*/
class SimpleInterest{
public static void main(String args[]){
double pr, ra;
int t, n;
Scanner inp = new Scanner(System.in);
System.out.println(“Enter the Principle: “);
pr= inp.nextDouble();
System.out.println(“Enter the Rate: “);
ra = inp.nextDouble();
System.out.println(“Enter the Time Period: “);
t=inp.nextInt();
System.out.println(“Enter the Frequency: “);
n=inp.nextInt();
double si=pr*ra*t;
si /= n*100;
System.out.println(“Calculated S.I. “+si);
}
}
[/java]