# Interest Calculator – Interface Concept Program in java

In this post, we will learn Interest Calculator – Interface Concept Program in java Programming language.

## Question:

MyBank wants to create an interest calculator module to benefit the customers for checking the interest that the customer has to pay for the amount that he receives from the bank as a loan. Help MyBank in implementing the same

1. Create an interface Percentage with the below attribute and abstract method.

float rateOfInterest = 10.5 ;

double calculateInterest(double amount)  –  abstract method to calculate the interest amount for the principle amount passed as parameter and mentioned rate of interest. Return the interest amount.

Create a class called “InterestCalc” that implemets the interface “Percentage”.

Provide implementation for the calculateInterest method in the interestCalc class.

Create a class called Interest with the main method. From this main method invoke the calculateInterest method of InterestCalc class.

Display the result as shown in the sample output

Sample Input and Output :

Enter the amount for which interest must be calculated

3500000

The interest amount to be paid is

367500

### CODE:–

```import java.util.Scanner;
interface Percentage{
float rateOfInterest=(float)10.5;
public abstract double calculateInterest(double amount);
}
class InterestCalc implements Percentage{
public double calculateInterest(double amount){
return amount*this.rateOfInterest/100;
}
}
public class Interest{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
Percentage i=new InterestCalc();
System.out.println("Enter the amount for which interest must be calculated");
double amount=sc.nextDouble();
System.out.println("The interest amount to be paid is");
System.out.println((int)(i.calculateInterest(amount)));
}
}	```
```public class Student
{
private int id;
private String name;
private int[] marks;
private float average;
public void setId(int id)
{
this.id=id;
}
public int getId()
{
return this.id;
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
public void setMarks(int[] marks)
{
this.marks=marks;
}
public int[] getMarks()
{
return this.marks;
}
public void calculateAvg()
{   float sum=0;
for(int i=0;i<this.marks.length;i++)
{
sum+=this.marks[i];
}
average=(float)(sum/(this.marks.length));
setAverage(average);
}
{int flag=0;
for(int i=0;i<this.marks.length;i++)
{
if(this.marks[i]<50)
{
flag++;
}
}
if(flag>0)
{
}
else
{
if(this.average>=80 && this.average<=100)
{
}
else if(this.average>=50 && this.average<=79)
{
}
else
{
}
}
}
public void setAverage(float average)
{
this.average=average;
}