Account.Java:public class Account{
private String holderName;
private Long accountNumber;
private String IFSCCode;
private Long contactNumber;
public Account() {
super();
// TODO Auto-generated constructor stub
}
public String getHolderName() {
return holderName;
}
public void setHolderName(String holderName) {
this.holderName = holderName;
}
public Long getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(Long accountNumber) {
this.accountNumber = accountNumber;
}
public String getIFSCCode() {
return IFSCCode;
}
public void setIFSCCode(String iFSCCode) {
IFSCCode = iFSCCode;
}
public Long getContactNumber() {
return contactNumber;
}
public void setContactNumber(Long contactNumber) {
this.contactNumber = contactNumber;
}
public Account(String holderName, Long accountNumber, String iFSCCode, Long contactNumber) {
super();
this.holderName = holderName;
this.accountNumber = accountNumber;
IFSCCode = iFSCCode;
this.contactNumber = contactNumber;
}
public void display() {
System.out.println("HolderName : "+getHolderName());
System.out.println("Account Number : "+getAccountNumber());
System.out.println("IFSCCode : "+getIFSCCode());
System.out.println("ContactNumber : "+getContactNumber());
}
}
SavingsAccount.Java:public class SavingsAccount extends Account {
private Double interestRate;
public SavingsAccount(String holderName, Long accountNumber, String iFSCCode, Long contactNumber, Double interestRate) {
super(holderName, accountNumber, iFSCCode, contactNumber);
this.interestRate = interestRate;
}
public Double getInterestRate() {
return interestRate;
}
public void setInterestRate(Double interestRate) {
this.interestRate = interestRate;
}
public void display() {
System.out.println("Your Contact Details");
System.out.println("HolderName : "+getHolderName());
System.out.println("Account Number : "+getAccountNumber());
System.out.println("IFSCCode : "+getIFSCCode());
System.out.println("ContactNumber : "+getContactNumber());
System.out.println("Interest Rate : "+String.format("%.2f",getInterestRate()));
}
}
CurrentAccount.Java:public class CurrentAccount extends Account{
private String organizationName;
private Long TIN;
public CurrentAccount(String holderName, Long accountNumber, String iFSCCode, Long contactNumber,
String organizationName, Long tIN) {
super(holderName, accountNumber, iFSCCode, contactNumber);
this.organizationName = organizationName;
TIN = tIN;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public Long getTIN() {
return TIN;
}
public void setTIN(Long tIN) {
TIN = tIN;
}
public void display() {
System.out.println("Your Contact Details");
System.out.println("HolderName : "+getHolderName());
System.out.println("Account Number : "+getAccountNumber());
System.out.println("IFSCCode : "+getIFSCCode());
System.out.println("ContactNumber : "+getContactNumber());
System.out.println("Organization Name : "+getOrganizationName());
System.out.println("TIN : "+getTIN());
}
}
Main.java:import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter User Details(HolderName,Account Number,IFSC code,Contact Number)");
String details=sc.nextLine();
String[] str=details.split(",");
Long accNo=Long.parseLong(str[1]);
Long conNum=Long.parseLong(str[3]);
System.out.println("Enter Account Type");
String type=sc.nextLine();
if(type.equals("savings"))
{
System.out.println("Enter Interest Rate");
Double i=sc.nextDouble();
Account sa = new SavingsAccount(str[0],accNo,str[2],conNum,i);
sa.display();
}
else if(type.equals("current"))
{
System.out.println("Enter organization Name");
String org=sc.nextLine();
System.out.println("Enter TIN number");
Long tin=sc.nextLong();
Account ca = new CurrentAccount(str[0],accNo,str[2],conNum,org,tin);
ca.display();
}
else
{
System.out.println("Enter valid Account Type");
}
}
}