Re: can u give me this program
my code is like this
package com;
import java.util.ArrayList;
import java.util.Random;
public class Bank {
String AccID;
ArrayList<Bank> national;
ArrayList<Bank> privte;
public String getCustomerID(String bankName,String accType )
{
String randomString;
Random randomGenerator = new Random();
int randomInt=randomGenerator.nextInt();
randomString=Integer.toString(randomInt);
AccID=bankName.concat(randomString);
return AccID;
}
}
package com;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BankTest {
public static void main(String[] args) throws IOException {
String accType;
String bankType;
String bankName;
String SbankOption;
int bankOption;
// String AccID;
Bank b;
int minibal;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nChoose the Account type:\n1.Savings Bank(SB)
\n2.Fixed Deposit(FD)\n");
accType=br.readLine();
System.out.println("\nChoose the type of bank:\n");
System.out.println("1.Nationalised Bank\n2.Private Bank");
bankType=br.readLine();
System.out.println("Choose one of the banks:");
if(bankType.equals("1"))
{
National n=new National();
n.listNationalBanks();
SbankOption=br.readLine();
bankOption=Integer.parseInt(SbankOption);
bankName=n.getBankName(bankOption);
minibal=n.minbal;
b=n.getBankObject(bankName);
}
else
{
Private p=new Private();
p.listPrivateBanks();
SbankOption=br.readLine();
bankOption=Integer.parseInt(SbankOption);
bankName=p.getBankName(bankOption);
minibal=p.minbal;
b=p.getBankObject(bankName);
}
//AccID=b.getCustomerID(bankName,accType);
Customer cust=new Customer();
if(accType.equalsIgnoreCase("1"))
{
cust.openSB(b, minibal);
cust.SBoperations(cust);
}
else
{
cust.openFD(b, minibal);
}
}
}
package com;
import java.util.Random;
public class CITI extends Private{
float rti=(float)7.5;
}
package com;
import java.util.Random;
public class Corporate extends National{
float rti=(float)10;
}
package com;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Customer {
String AccID;
int AccBal=0;
float FDamt=0;
public void depositMoney() throws NumberFormatException, IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nEnter the deposit amount: ");
int amt=Integer.parseInt(br.readLine());
AccBal+=amt;
}
public void withdrawMoney() throws NumberFormatException, IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nEnter the withdrawl amount: ");
int amt=Integer.parseInt(br.readLine());
AccBal-=amt;
}
public void viewBalance()
{
System.out.println("\nDear customer, the current balance in your
account is Rs."+AccBal);
}
public void openSB(Bank bb,int minibal) throws NumberFormatException,
IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nDeposit money to open SB account: Minimum
amount is Rs."+minibal);
AccBal=Integer.parseInt(br.readLine());
while(AccBal < minibal)
{
System.out.println("Please enter greater than Rs."+minibal);
AccBal=Integer.parseInt(br.readLine());
}
System.out.println("\nSB Account created successfully");
}
public void openFD(Bank bb, int minibal) throws
NumberFormatException, IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nEnter the following details to open FD account:
\n");
System.out.println("\nEnter the amount (in Rs.) = ");
FDamt=Float.parseFloat(br.readLine());
while(FDamt < 1000)
{
System.out.println("Please enter the amount greater than or equal
to Rs.1000");
FDamt=Float.parseFloat(br.readLine());
}
System.out.println("Enter the period in months: ");
int period=Integer.parseInt(br.readLine());
System.out.println("\nFD Account created successfully\n\n");
FDdetails(bb,FDamt,period);
}
public void SBoperations(Customer cust) throws IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("\nChoose one of the transactions:");
System.out.println("1.Deposit money\n2.Withdraw money\n3.View Balance
\n0.Exit");
String t=br.readLine();
while(!(t.equalsIgnoreCase("0")))
{
if(t.equalsIgnoreCase("1"))
{
cust.depositMoney();
}
else if(t.equalsIgnoreCase("2"))
{
cust.withdrawMoney();
}
else
{
cust.viewBalance();
}
System.out.println("1.Deposit money\n2.Withdraw money\n3.View Balance
\n0.Exit");
t=br.readLine();
}
}
public void FDdetails(Bank bb, float principal, int period)
{
//float rateofinterest;
//float AccountBalance;
float interest;
float time=(float)period/12;
float rti=9;
System.out.println("\nPrincipal Amount = Rs."+principal);
System.out.println("Time period = Rs."+time);
System.out.println("Rate of Interest = "+rti);
interest=(principal*time*rti)/100;
System.out.println("Interest credited after "+period+" months =
Rs."+interest);
float amount=principal+interest;
System.out.println("\nTotal Amount = Rs."+amount);
}
}
package com;
import java.util.Random;
public class HDFC extends Private{
float rti=(float)7;
}
package com;
import java.util.Random;
public class ICICI extends Private{
float rti=(float)8;
}
package com;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
public class National extends Bank{
final int minbal=5000;
ArrayList<String> nationalbanks = new ArrayList<String>();
public void listNationalBanks()
{
nationalbanks.add("SBI");
nationalbanks.add("Corporate");
nationalbanks.add("Syndicate");
int count =1;
for(String natBank:nationalbanks)
{
System.out.println(count+"."+natBank+"\n");
count++;
}
}
public String getBankName(int bankIndex)
{
return nationalbanks.get(bankIndex);
}
public National getBankObject(String bankName)
{
if(bankName.equalsIgnoreCase("SBI"))
{
SBI b=new SBI();
return b;
}
else if(bankName.equalsIgnoreCase("Corporate"))
{
Corporate b= new Corporate();
return b;
}
else
{
Syndicate b=new Syndicate();
return b;
}
}
}
package com;
import java.util.ArrayList;
import java.util.Iterator;
public class Private extends Bank{
ArrayList<String> privatebanks = new ArrayList<String>();
final int minbal=10000;
public void listPrivateBanks()
{
privatebanks.add("CITI");
privatebanks.add("ICICI");
privatebanks.add("HDFC");
int count =1;
for(String pvtBank:privatebanks)
{
System.out.println(count+"."+pvtBank+"\n");
count++;
}
}
public String getBankName(int bankIndex)
{
return privatebanks.get(bankIndex);
}
public Private getBankObject(String bankName)
{
if(bankName.equalsIgnoreCase("CITI"))
{
CITI b=new CITI();
return b;
}
else if(bankName.equalsIgnoreCase("ICICI"))
{
ICICI b= new ICICI();
return b;
}
else
{
HDFC b=new HDFC();
return b;
}
}
}
package com;
public class SBI extends National{
float rti=(float)9;
}
package com;
public class Syndicate extends National{
float rti=(float)8.5;
}
this is my code but getting some mistakes