Sunteți pe pagina 1din 9

// ----------------------------------------CASE Study sa JAVA---------------------------------------------------import java.text.*; import java.io.

*; public class AutoTellerMachine { public static void main (String[] args)throws Exception { //declaration String start,strbal,strexit,stradmin; char chTransac,chBal,chExodus,chadmstr; int intPin,intEdit,intChange,intExtra=20; double dblWithdraw,dblDeposit; //df format in money DecimalFormat df = new DecimalFormat("0.00"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Arrays String acctnos[] = {"0123-4567-8901", "2345-6789-0123", "3456-7890-1234", "4567-89012345", "5678-9012-3456"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "}; String acctname[] = {"Roel Richard\t", "Dorie Marie\t\t", "Railee Darrel\t", "Railynne Desiree", "Raine Desiree\t"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "}; double dblBal[] = { 5000.00, 0.00, 10000, 2500, 10000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int arrPins[] = {1111, 2222, 3333, 4444, 5555,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //Texts shortcut Messages RGBC= new Messages (); Messages output1= new Messages(); Messages output3= new Messages(); Messages output4= new Messages(); Messages adminchoice= new Messages(); Messages info= new Messages(); Messages exiting= new Messages(); Messages actnumber= new Messages(); Messages actname= new Messages(); Messages actpin= new Messages(); Messages labas= new Messages(); RGBC.setTitle("\t\t\tRGBC\n Richard Gwapo Banking Corporation\n_________________________________\n\n"); output1.setTitle("\t\t\tRGBC\n Richard Gwapo Banking Corporation\n__________________________________\n\n S- Start Application\n Q-Quit Application\n\nEnter Choice:"); output3.setTitle("\t\t\tRGBC\n Richard Gwapo Banking Corporation\n___________________________________\n\nEnter your pin number:");

output4.setTitle("\t\t\tRGBC\n Richard Gwapo Banking Corporation\n____________________________________\nSelect Type of Transaction\nB -> Balance Inquiry\nW -> Withdrawal\nD -> Deposit\nC -> Cancel\n\nEnter your transaction: "); adminchoice.setTitle("\nWhat would you like to do?\n\n(V)-View Customer Information\n(A)-Add New Customer\n(E)-Edit Customer Information\n(C)-Change Customer Pin Number\n(X)-Exit\n\nEnter your choice: "); info.setTitle("\nAccount Number\tAccount Name\t\tPin Number\tBalance"); exiting.setTitle("\nPress x to continue..."); actnumber.setTitle("\nAccount Number of the customer: "); actname.setTitle("\nName of the customer:"); actpin.setTitle("Customer PIN Number:"); labas.setTitle("Press X to exit"); //output 1 loop aaa: for (int user = 0, counter=1; user < counter; user++) { System.out.print (output1.getTitle()); start = br.readLine(); counter++; chTransac = start.charAt(0); //if 'S' is inputted switch(chTransac) { case 'S': case 's': //password input is limited to three for(int pincount = 0; pincount < 3; pincount++) { System.out.print (output3.getTitle()); intPin = Integer.parseInt(br.readLine()); bbb: for(int pincheck = 0; pincheck<intPin+1; pincheck++) { if (intPin==0) { System.out.print (RGBC.getTitle()+adminchoice.getTitle()); stradmin = br.readLine(); chadmstr = stradmin.charAt(0); switch(chadmstr) { // if v is inputted view all customers case 'V':

case 'v': System.out.println (info.getTitle()); for(int acctindex = 0; acctindex < acctname.length-intExtra; acctindex++) { System.out.println (acctnos[acctindex]+"\t"+acctname[acctindex]+"\t"+arrPins[acctindex]+"\t\t"+df.format(dblBal[ acctindex])); } System.out.print(exiting.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'x'||chExodus == 'X') continue bbb; // if a is inputted add new customer case 'A': case 'a': System.out.print (actnumber.getTitle()); acctnos[acctname.length - intExtra] = br.readLine(); System.out.print (actname.getTitle()); acctname[acctname.length - intExtra] = br.readLine(); System.out.print (actpin.getTitle()); arrPins[acctname.length - intExtra] = Integer.parseInt(br.readLine()); dblBal[acctname.length - intExtra] = 0.0; intExtra--; System.out.print (exiting.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'X'||chExodus == 'x') continue bbb; //if e is inputted, edit customers case 'E': case 'e': System.out.print ("\nInput customer's Pin: "); intEdit = Integer.parseInt(br.readLine()); for(int acctnew = 0; acctnew < arrPins.length-intExtra; acctnew++) { if(intEdit == arrPins[acctnew]) { System.out.print ("\nInput customer's new Account Name: ");

acctname[acctnew] = br.readLine(); System.out.print ("\nInput customer's new Account Number: "); acctnos[acctnew] = br.readLine(); } } System.out.print (exiting.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'X'||chExodus == 'x') continue bbb; // if c is inputted change password case 'C': case 'c': System.out.print ("\nInput customer's Pin: "); intChange = Integer.parseInt(br.readLine()); for(int acctnew = 0; acctnew < arrPins.length-intExtra; acctnew++) { if(intChange == arrPins[acctnew]) { System.out.print ("\nInput customer's new Pin: "); arrPins[acctnew] = Integer.parseInt(br.readLine()); } } System.out.print (exiting.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'X'||chExodus == 'x') continue bbb; //if x is inputted go back to output1 loop case 'X': case 'x': continue aaa; } } ccc: //output for regular customer //password limited to three for (int customerpincheck = 0; customerpincheck < intPin; customerpincheck++)

{ // check if pin is in the list for(int index = 0; index < arrPins.length-intExtra ;index++) { if(intPin==arrPins[index]) { System.out.print (output4.getTitle()); strbal = br.readLine(); chBal = strbal.charAt (0); switch(chBal) { //balance function case 'B': case 'b': System.out.println (RGBC.getTitle()+"\nAccount #:"+acctnos[index]+"\nAccount Name:"+acctname[index]+"\nBalance: "+dblBal[index]+"\n\n"+labas.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'X'||chExodus == 'x') continue ccc; // withrawal function case 'W': case 'w': System.out.println (RGBC.getTitle()+"\nEnter Amount to be withdrawn\t\t"); dblWithdraw = Double.parseDouble(br.readLine()); if((dblWithdraw >=100)&&((dblWithdraw/50)%2 == 0)&&(dblWithdraw!=0.0)) {dblBal[index]-= dblWithdraw; System.out.print (labas.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); if(chExodus == 'X'||chExodus == 'x') continue ccc; } else //if invalid input of withdraw {System.out.println ("* Valid amount: 100, 200, 1700... etc(100 denominations)\n* Invalid amount: 450, 10, 1000.25... etc"); System.out.println (labas.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0);

continue ccc;}

case 'D': case 'd': //deposit function System.out.println (RGBC.getTitle()+"\nEnter Amount to be deposited\t\t"); dblDeposit = Double.parseDouble(br.readLine()); dblBal[index]+=dblDeposit; System.out.println (labas.getTitle()); strexit = br.readLine(); chExodus = strexit.charAt(0); continue ccc; //if cancel, go to output1 loop case 'C': case 'c': continue aaa; // if inputted letter is not on the list default: System.out.println ("\n\nPlease Input the Correct Letter!\n"); continue ccc; } } } //if inputting password reached 3 if(pincount == 2) { pincheck+=1000000; customerpincheck+=100000; System.out.println ("\n\nCAPTURED CARD!!! PLEASE CALL 143-44");} // if wrong password else { pincheck+=1000000; customerpincheck+=1000000; System.out.println ("\n\nInput the correct pin number!");} } } } // if Q is inputted

case 'Q': case 'q': System.exit(0); //if wrong letter is inputted default: System.out.println ("\n\nPlease Input Correct Letter!\n"); } } } }

CLASS MESSAGES public class Messages { public String title; public String getTitle(){ return title; } public void setTitle(String labels){ title = labels; } }

UNIVERSITY OF MAKATI J.P. Rizal Ext., West Rembo, Makati City

Final Case Study in ITC33-OOP JAVA

Submitted by: Cacela, Arcie Q. Dela Cruz, John Chris G. Galarosa, Hernel M. Moaa, John Nikko V.

Submitted to: Mrs. Emily Franco Sicat

SAMPLE OUTPUT

S-ar putea să vă placă și