Program for Simple Interest.

import java.io.*;
class SimpleInterest
{
int principle;
double rate;
int no_of_yrs;
double si;
void accept()
{
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

System.out.print("Enter The Principle Amount : ");
principle = Integer.parseInt(br.readLine());

System.out.print("Enter the Rate of Interest : ");
rate = Double.parseDouble(br.readLine());

System.out.print("Enter the No. of Years : ");
no_of_yrs = Integer.parseInt(br.readLine());

si = (principle*rate*no_of_yrs)/100;
}
catch(Exception e)
{
System.out.println("IOException Error!");
}
}
void display()
{
System.out.println("Principle Amount : "+principle);
System.out.println("Rate Of Interest : "+rate);
System.out.println("No. Of Years : "+no_of_yrs);
System.out.println("Simple Interest : "+si);
}
};
class Exp5_1
{
public static void main(String[] args)
{
SimpleInterest s = new SimpleInterest();
s.accept();
s.display();
}
}

No comments:

Post a Comment