import java.io.*; class banking { static String a; static int numacc; static String data[]; static String data_acc[]; static float accounts[][]; static float ammount; static int bank_code; static int acc_code; static String scnd_data_acc[]; static int scnd_bank_code; static int scnd_acc_code; public static void main(String args[]){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while(!(a = br.readLine()).equals("0")) { accounts = new float[10][10000]; numacc = Integer.parseInt(a); ///////nacteni uctu for(int i = 0; i < numacc; i++) { a = br.readLine(); data = a.split(" "); ammount = Float.parseFloat(data[1]); data_acc = data[0].split("/"); bank_code = Integer.parseInt(data_acc[1]); acc_code = Integer.parseInt(data_acc[0]); accounts[bank_code][acc_code] = ammount + 1; } //////cteni operaci while(!(a = br.readLine()).equals("end")){ data = a.split(" "); if(data[0].equals("create")){ data_acc = data[1].split("/"); bank_code = Integer.parseInt(data_acc[1]); acc_code = Integer.parseInt(data_acc[0]); if(accounts[bank_code][acc_code] > 0) System.out.println("create: already exists");else {accounts[bank_code][acc_code] = 1; System.out.println("create: ok"); } } if(data[0].equals("deposit")){ data_acc = data[1].split("/"); bank_code = Integer.parseInt(data_acc[1]); acc_code = Integer.parseInt(data_acc[0]); if(accounts[bank_code][acc_code] > 0) { accounts[bank_code][acc_code] += Float.parseFloat(data[2]); System.out.println("deposit " + data[2] + ": ok"); } else System.out.println("deposit " + data[2] + ": no such account"); } if(data[0].equals("withdraw")){ data_acc = data[1].split("/"); bank_code = Integer.parseInt(data_acc[1]); acc_code = Integer.parseInt(data_acc[0]); if(accounts[bank_code][acc_code] > 0) { if((accounts[bank_code][acc_code]-1) > Float.parseFloat(data[2])){ accounts[bank_code][acc_code] -= Float.parseFloat(data[2]); System.out.println("withdraw " + data[2] + ": ok"); } else System.out.println("withdraw " + data[2] + ": insufficient funds"); } else System.out.println("withdraw " + data[2] + ": no such account"); } if(data[0].equals("transfer")){ data_acc = data[1].split("/"); bank_code = Integer.parseInt(data_acc[1]); acc_code = Integer.parseInt(data_acc[0]); scnd_data_acc = data[2].split("/"); scnd_bank_code = Integer.parseInt(scnd_data_acc[1]); scnd_acc_code = Integer.parseInt(scnd_data_acc[0]); if(accounts[bank_code][acc_code] > 0){ if(accounts[scnd_bank_code][scnd_acc_code] > 0) { if(!data[1].equals(data[2])) { if((accounts[bank_code][acc_code]-1) > Float.parseFloat(data[3])){ accounts[bank_code][acc_code] -= Float.parseFloat(data[3]); accounts[scnd_bank_code][scnd_acc_code] += Float.parseFloat(data[3]); if(bank_code != scnd_bank_code) System.out.println("transfer " + data[3] + ": interbank"); else System.out.println("transfer " + data[3] + ": ok"); } else System.out.println("transfer " + data[3] + ": insufficient funds"); } else System.out.println("transfer " + data[3] + ": same account"); } else System.out.println("transfer " + data[3] + ": no such account"); } else System.out.println("transfer " + data[3] + ": no such account"); } if((in = br.readLine()) == null) continue; else break; } } System.out.println("goodbye"); } catch(IOException e){} } }