Loading
View RSS Feed

torus

TCS ILP Assignment : Monopoly Bank Case Study In Java

Rating: 14 votes, 4.64 average.
Monopoly bank offers various fixed deposit schemes. Customers of the bank can choose to deposit money under various schemes. For every scheme there is a minimum amount of money that should be deposited. An interest is paid for the deposit amount as mentioned in the scheme under which deposit is made. Every scheme states a time period for which the money is deposited. A penalty amount as specified by the scheme needs to be paid if the money needs to be withdrawn before the mentioned period. In this case interest will be paid only for the time period for which money was deposited. Write a program to:
a. Add a new scheme
b. Add a new customer
c. Open a deposit for a customer
d. Calculate amount payable for a deposit, at the end of deposit period
e. Calculate amount payable for a deposit, if the money is withdrawn before specified period

Click image for larger version. 

Name:	Scheme2.JPG 
Views:	3933 
Size:	34.3 KB 
ID:	1052
Click image for larger version. 

Name:	Scheme1.JPG 
Views:	4006 
Size:	39.6 KB 
ID:	1051


Main class
Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
    
    public static void main(String args[]) throws Exception
    {
        ArrayList<Scheme> schemeList=new ArrayList<Scheme>();
        ArrayList<Customer> custList=new ArrayList<Customer>();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int i=0,n=1,id=1,accountNo=001;
        while(i==0)
        {
            System.out.println("1.Add schemme\n2.Add customer\n3.Open deposit\n4.Calculate interest\n5.Calculate interest before time period");
            System.out.println("Enter choice:");
            int choice=Integer.parseInt(br.readLine());
            switch(choice)
            {
                case 1:System.out.println("Enter the minimum amount for scheme:");
                        int minAmount=Integer.parseInt(br.readLine());
                        System.out.println("Enter the time period (yrs)for scheme:");
                        int timePeriod=Integer.parseInt(br.readLine());
                        System.out.println("Enter the interest for scheme:");
                        float interest=Float.parseFloat(br.readLine());
                        System.out.println("Enter the penalty amount for scheme:");
                        int penalty=Integer.parseInt(br.readLine());
                        Scheme sNew=new Scheme(n++, minAmount, interest, timePeriod, penalty);
                        schemeList.add(sNew);
                        System.out.println("The new scheme id is:"+sNew.getSchemeId());
                        break;
                case 2:    System.out.println("Enter the name :");
                        String name=br.readLine();
                        Customer cNew=new Customer(name,id++,null,0);
                        custList.add(cNew);
                        System.out.println("The customer id is:"+cNew.getId());
                        break;
                case 3:    System.out.println("Enter customer id:");
                        int custId=Integer.parseInt(br.readLine());
                        int flag=0;
                        for(Customer c:custList)
                        {
                            if(c.getId()==custId)
                            {
                                flag=1;
                                break;
                            }
                        }
                        if(flag==0)
                        {        
                            System.out.println("No such customer!!");
                            break;
                        }
                        else if(schemeList.size()==0)
                            System.out.println("No schemes!!");
                        else
                        {
                            System.out.println("The schemes are as follows:");
                            for(Scheme s:schemeList)
                            {
                            System.out.println("Scheme id:"+s.getSchemeId());
                            System.out.println("Minimum Amount:"+s.getMinAmount());
                            System.out.println("Interest:"+s.getInterest());
                            System.out.println("Time period(yrs):"+s.getTimePeriod());
                            System.out.println("Penalty(in Rs):"+s.getPenaltyAmount());
                            System.out.println();
                            }
                            System.out.println("Choose the scheme id:");    
                            int schemeId=Integer.parseInt(br.readLine());
                            System.out.println("Enter the deposit amount:");
                            int amount=Integer.parseInt(br.readLine());
                            flag=0;
                            for(Scheme s:schemeList)
                            {
                                if(s.getSchemeId()==schemeId && s.getMinAmount()<=amount)
                                {
                                    flag=1;
                                    for(Customer c:custList)
                                    {
                                        if(c.getId()==custId)
                                        {
                                            c.setScheme(s);
                                            c.setDepositAccountNo(accountNo++);
                                            c.setDepositAmount(amount);
                                            System.out.println("Your deposit account no is:"+c.getDepositAccountNo());
                                        }
                                    }
                                }    
                            }
                            if(flag==0)
                                System.out.println("Enter valid scheme id and valid amount!!");
                        }    
                        break;
                case 4:System.out.println("Enter customer id:");
                        custId=Integer.parseInt(br.readLine());
                        flag=0;
                        for(Customer c:custList)
                        {
                            if(c.getId()==custId)
                            {
                                flag=1;
                                double temp=(1+(c.getScheme().getInterest())/100);
                                temp=Math.pow(temp,c.getScheme().getTimePeriod());
                                double interestCal=c.getDepositAmount()*temp;
                                System.out.println("The interest calculated is:"+interestCal);
                                System.out.println("The amount payable:"+(c.getDepositAmount()+interestCal));
                            }
                        }    
                        if(flag==0)
                            System.out.println("Enter valid customer id!!");
                        break;    
                case 5:System.out.println("Enter customer id:");
                        custId=Integer.parseInt(br.readLine());
                        System.out.println("Enter the time period:");
                        int period=Integer.parseInt(br.readLine());
                        flag=0;
                        for(Customer c:custList)
                        {
                            if(c.getId()==custId && period<=c.getScheme().getTimePeriod())
                            {
                                flag=1;
                                double temp=(1+(c.getScheme().getInterest())/100);
                                temp=Math.pow(temp,period);
                                double interestCal=c.getDepositAmount()*temp;
                                System.out.println("The interest calculated is:"+interestCal);
                                System.out.println("The amount payable:"+(c.getDepositAmount()+interestCal+c.getScheme().getPenaltyAmount()));
                            }
                        }    
                        if(flag==0)
                            System.out.println("Enter valid customer id and valid time period!!");
                        break;        
                default:System.out.println("Enter valid choice!!");
                        break;
            }
        }
    }
}

Scheme class
Code:
public class Scheme {
    int schemeId;
    int minAmount;
    float interest;
    int timePeriod;
    int penaltyAmount;
    
    public int getSchemeId() {
        return schemeId;
    }
    public Scheme(int schemeId, int minAmount, float interest, int timePeriod,
            int penaltyAmount) {
        super();
        this.schemeId = schemeId;
        this.minAmount = minAmount;
        this.interest = interest;
        this.timePeriod = timePeriod;
        this.penaltyAmount = penaltyAmount;
    }
    public void setSchemeId(int schemeId) {
        this.schemeId = schemeId;
    }
    public int getMinAmount() {
        return minAmount;
    }
    public void setMinAmount(int minAmount) {
        this.minAmount = minAmount;
    }
    public float getInterest() {
        return interest;
    }
    public void setInterest(float interest) {
        this.interest = interest;
    }
    public int getTimePeriod() {
        return timePeriod;
    }
    public void setTimePeriod(int timePeriod) {
        this.timePeriod = timePeriod;
    }
    public int getPenaltyAmount() {
        return penaltyAmount;
    }
    public void setPenaltyAmount(int penaltyAmount) {
        this.penaltyAmount = penaltyAmount;
    }

}
Customer class:
Code:
public class Customer {
    
String name;
int id;
Scheme scheme;
int depositAccountNo;
int depositAmount;

public Customer(String name, int id, Scheme scheme, int depositAccountNo) {
    super();
    this.name = name;
    this.id = id;
    this.scheme = scheme;
    this.depositAccountNo = depositAccountNo;
}
public int getDepositAmount() {
    return depositAmount;
}
public void setDepositAmount(int depositAmount) {
    this.depositAmount = depositAmount;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public Scheme getScheme() {
    return scheme;
}
public void setScheme(Scheme scheme) {
    this.scheme = scheme;
}
public int getDepositAccountNo() {
    return depositAccountNo;
}
public void setDepositAccountNo(int depositAccountNo) {
    this.depositAccountNo = depositAccountNo;
}

}

Submit "TCS ILP Assignment : Monopoly Bank Case Study In Java" to Digg Submit "TCS ILP Assignment : Monopoly Bank Case Study In Java" to del.icio.us Submit "TCS ILP Assignment : Monopoly Bank Case Study In Java" to StumbleUpon Submit "TCS ILP Assignment : Monopoly Bank Case Study In Java" to Google

Categories
Java

Comments

  1. nitinteja.jasti's Avatar
    Thank u !!!!
  2. angad's Avatar
    Thanks Torus for solving this problem. I request each member to contribute and help each other so we all can learn.



Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.