# Question: Lab 3 Your task is to create simple deposit/credit calculator for… -Free Course Hero Question Answer.

Question Description: Lab 3 Your task is to create simple deposit/credit calculator for…

Image transcription text

Find below the classes

``````package Bank;

public class Calculator {

private final double RATEFORINDIVIDUAL = 0.08;
private final double RATEFORLEGALENTITIES = 0.10;

public double depositReward(double amount, double durationInYears, ClientType clientType){
switch (clientType){
case INDIVIDUAL:
return (amount * durationInYears * RATEFORINDIVIDUAL);
case LEGAL_ENTITY:
return (amount * durationInYears * RATEFORLEGALENTITIES);
default: return 0;
}
}

public double calculateCredit(double amount, double durationInYears, ClientType clientType){
switch (clientType){
case INDIVIDUAL:
return (amount * durationInYears * RATEFORINDIVIDUAL);
case LEGAL_ENTITY:
return (amount * durationInYears * RATEFORLEGALENTITIES);
default: return 0;
}
}

}``````
``````package Bank;

public class NationalBank {
private final double FIXEDBANKREWARD = 0.01;
public Calculator calculator;

public NationalBank() {
this.calculator = new Calculator();
}

public double calculateDeposit(double amount, double durationInMonths, ClientType clientType){
return calculator.depositReward(amount, durationInMonths, clientType) * FIXEDBANKREWARD;
}

public double calculateCredit(double amount, double durationInMonths, ClientType clientType){
return calculator.calculateCredit(amount, durationInMonths, clientType) * FIXEDBANKREWARD;
}
}``````
``````package Bank;

public class SecondTierBank extends NationalBank{
private final double FIXEDBANKREWARD = 0.02;
private final double FIXEDINTERESTRATE = 0.03;

public SecondTierBank() {
super();
}

@Override
public double calculateCredit(double amount, double durationInYears, ClientType clientType){
return calculator.calculateCredit(amount, durationInYears, clientType) * FIXEDINTERESTRATE;
}
}``````
``````package Bank;

import java.util.Scanner;

public class main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
//Take input as per requirement

NationalBank nationalBank = new NationalBank();
SecondTierBank secondTierBank = new SecondTierBank();
System.out.println(nationalBank.calculateDeposit( 1000, 1, ClientType.INDIVIDUAL));
System.out.println(nationalBank.calculateDeposit( 1000, 1, ClientType.LEGAL_ENTITY));
System.out.println(secondTierBank.calculateDeposit( 1000, 1, ClientType.INDIVIDUAL));
System.out.println(secondTierBank.calculateDeposit( 1000, 1, ClientType.LEGAL_ENTITY));

System.out.println(nationalBank.calculateCredit( 1000, 1, ClientType.INDIVIDUAL));
System.out.println(nationalBank.calculateCredit( 1000, 1, ClientType.LEGAL_ENTITY));
System.out.println(secondTierBank.calculateCredit( 1000, 1, ClientType.INDIVIDUAL));
System.out.println(secondTierBank.calculateCredit( 1000, 1, ClientType.LEGAL_ENTITY));
}
}``````

You can change the logic of the calculator and use inputs as per your requirement.