Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

import java.util.

Scanner;
class SimpleInterest
{
float principle;
int time;
float rate;
// Constructor
SimpleInterest()
{
principle =0.0f;
rate = 0.0f;
time =0;
}

// Getting Data From User


void getdata()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the principle ");
principle = sc.nextFloat();
System.out.println("Enter the Rate ");
rate = sc.nextFloat();
System.out.println("Enter the Time ");
time = sc.nextInt();
}
// Calculating Simple Interest
double calculate()
{return((principle * rate * time)/100);}

void print()
{
System.out.println("\n Principle = "+principle);
System.out.println(" Rate = "+rate);
System.out.println("Time = "+time);
System.out.println("\n Amount = "+calculate());
}

}
class Test
{
public static void main(String args[])
{
SimpleInterest ob = new SimpleInterest();
ob.getdata();
ob.print();
}
}

You might also like