Let us create a program that will accept the amount and the time for fixed deposit and calculate the interest along with the Net Payable amount
Let us create a program that will accept the amount and the time for fixed deposit and calculate the interest along with the Net Payable amount
public class FixedDeposit
{
int amount;
float time;
float interest;
float total;
static float rate = 8.5f;
public void accept(int a , float t){
amount=a;
time=t;
}
public void calc(){
interest =(amount*time*rate)/100;
total=amount+interest;
}
public void display(){
System.out.println("Amount: "+amount);
System.out.println("Time: "+time);
System.out.println("Rate: "+rate);
System.out.println("**************************");
System.out.println("Interest: "+interest);
System.out.println("Net Payable Amount: "+total);
}
public static void main(String args[]){
FixedDeposit obj = new FixedDeposit();
obj.accept(5000,4);
obj.calc();
obj.display();
}
}
Output
Amount: 5000
Time: 4.0
Rate: 8.5
**************************
Interest: 1700.0
Net Payable Amount: 6700.0
Comments
Post a Comment