How do I program the ATM to do graphic design?
PLZ help me:'(:(
kasraluckblack 0 Newbie Poster
package atmfile;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Guest
*/
public class Acounts {
private String FirstName;
private String LastName;
private int AccountNumber;
private int Balance;
private int Password;
public Acounts(String fName, String lName, int Pass, int aNum, int money) {
FirstName = fName;
LastName = lName;
Password = Pass;
AccountNumber = aNum;
Balance = money;
}
public void setFirstName(String FName) {//set and get function for private variables
FirstName = FName;
}
public String getFirstName() {
return FirstName;
}
public void setLastName(String LName) {
LastName = LName;
}
public String getLastName() {
return LastName;
}
public void setBalance(int Money) {
Balance = Money;
}
public int getBalance() {
return Balance;
}
public int getAccountNumber() {
return AccountNumber;
}
public int getPassword() {
return Password;
}
}
package atmfile;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Guest
*/
import java.io.FileNotFoundException;
import java.util.*;
public class ATM {
public static void main(String Args[]) throws FileNotFoundException {
int i = 0;
int AccontNum;
int j = 0;
String operation = "";
System.out.print("*************Welcome to Yazd University Bank*************");
BankOperations BO = new BankOperations();
Scanner input = new Scanner(System.in);
while (true) {
j = BO.CheckUserAndPass();
if (BO.ICheck == 0) {
if (j == 0) {
System.out.printf("Hello %s %s", BO.a2[BO.iTemp].getFirstName(), BO.a2[BO.iTemp].getLastName());
while (true) {
System.out.printf("\n1-View your Balance\n2-Withdraw money\n3-Deposit money\n4-Transfer money\n5-EXIT\n6-Close the program and save the settings");
operation = input.next();
if (operation.equals("1") == false && operation.equals("2") == false && operation.equals("3") == false && operation.equals("4") == false && operation.equals("5") == false&& operation.equals("6") == false) {
System.out.printf("You must choose a integer number between 1 and 5");
} else {
switch (Integer.valueOf(operation)) {
case 1: {
BO.viewBalance();
break;
}
case 2: {
BO.withdrawMoney();
break;
}
case 3: {
BO.DepopsitMoney();
break;
}
case 4: {
BO.TransferMoney();
break;
}
case 5: {
BO.EXIT();
break;
}
case 6:{
BO.Close();
break;
}
}
}
if (BO.Exit > 0) {
break;
}
}
}
if (BO.counter == 0) {
System.out.printf("This account is not exist");
} else {
if (j == 1) {
System.out.printf("Your Password is WRONG");
}
}
} else {
if (BO.l == 0) {
System.out.printf("you must enter an integer number");
}
}
}
}
}
package atmfile;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Guest
*/
import java.io.FileNotFoundException;
import java.util.*;
public class BankOperations {
Scanner input = new Scanner(System.in);
int l = 0;
int ICheck = 0;
int BALANCE;
int iTemp1 = 0;
int checker = 0;
int Exit = 0;
int i = 0;
int iTemp = 0;
int counter;
String depositMoney = "";
String Pass = "";
String TransferCash = "";
String FinalResult = "";
String Fname = "1524";
String Lname = "132";
String withdrawMoney = "";
String AccountNum = "";
SaveAndLoad sal = new SaveAndLoad("F:\\account.txt");
Acounts a2[];
public BankOperations() throws FileNotFoundException {//in constructor baraye in ast ke be mahze new kardane tabe ekantha sakhte shavand
sal.Load();
a2 = new Acounts[sal.a1];
for (i = 0; i < sal.a1; i++) {
a2[i] = new Acounts(sal.fname[i], sal.lname[i], sal.password[i], sal.accountNumber[i], sal.cash[i]);
}
sal.CloseInputFile();
}
public int checkInput(String a) {
int temp = 0;
int inputCheck = 0;
for (i = 0; i < a.length(); i++) {
temp = a.charAt(i);
if (temp < 48 || temp > 57) {
inputCheck++;
}
}
return inputCheck;
}
public int CheckUserAndPass() {
l = 0;
counter = 0;
ICheck = 0;
ATM atm = new ATM();
System.out.printf("\nPlease Enter Your Account Number:");
AccountNum = input.next();
ICheck = checkInput(AccountNum);
if (ICheck == 0) {
checker = 0;
for (i = 0; i < 5; i++) {
if (a2[i].getAccountNumber() == Integer.valueOf(AccountNum)) {
iTemp = i;
counter++;
break;
}
}
if (counter == 1) {
System.out.printf("\nPlese Enter Your Password:");
Pass = input.next();
ICheck = checkInput(Pass);
if (ICheck == 0) {
if (a2[iTemp].getPassword() != Integer.valueOf(Pass)) {
checker++;
}
} else {
System.out.printf("your password is WRONG");
l++;
}
} else {
checker++;
}
}
return checker;
}
public void viewBalance() {
Exit = 0;
System.out.printf("\nYour Balance is :%d\n", a2[iTemp].getBalance());
}
public void withdrawMoney() {
Exit = 0;
ICheck = 0;
withdrawMoney = "";
System.out.printf("Please Enter the withdraw money:");
withdrawMoney = input.next();
ICheck = checkInput(withdrawMoney);
if (ICheck == 0) {
if (Integer.valueOf(withdrawMoney) <= a2[iTemp].getBalance()) {
if (Integer.valueOf(withdrawMoney) >= 0) {
a2[iTemp].setBalance((a2[iTemp].getBalance() - Integer.valueOf(withdrawMoney)));
} else {
System.out.printf("your input must be a POSITIVE number.");
}
} else {
System.out.printf("you dont have enough money.");
}
} else {
System.out.printf("you must input an integer number");
}
}
public void DepopsitMoney() {
Exit = 0;
ICheck = 0;
depositMoney = "";
System.out.printf("Please Enter the deposit money:");
depositMoney = input.next();
ICheck = checkInput(depositMoney);
if (ICheck == 0) {
if (Integer.valueOf(depositMoney) >= 0) {
a2[iTemp].setBalance((a2[iTemp]).getBalance() + Integer.valueOf(depositMoney));
} else {
System.out.printf("your input must be a POSITIVE number.");
}
} else {
System.out.printf("you must input an integer number");
}
}
public void TransferMoney() {
while (true) {
counter = 0;
ICheck = 0;
Exit = 0;
ICheck = 0;
System.out.printf("Please Enter the destination account number:");
AccountNum = input.next();
ICheck = checkInput(AccountNum);
if (ICheck == 0) {
for (i = 0; i < 5; i++) {
if (a2[i].getAccountNumber() == Integer.valueOf(AccountNum)) {
iTemp1 = i;
counter++;
break;
}
}
if (counter == 1) {
System.out.printf("Please enter the transfer cash:");
TransferCash = input.next();
ICheck = checkInput(TransferCash);
if (ICheck == 0) {
if (Integer.valueOf(TransferCash) <= a2[iTemp].getBalance()) {
if (Integer.valueOf(TransferCash) >= 0) {
Fname = a2[iTemp1].getFirstName();
Lname = a2[iTemp1].getLastName();
System.out.printf("Are you sure that you want to transfer %s $ to %s %s accont?(1(Yes)/2(No))", TransferCash, Fname, Lname);
FinalResult = input.next();
if (FinalResult.equals("1") == false && FinalResult.equals("2") == false) {
System.out.printf("you must input 1 for yes or 2 for no.");
} else {
if (Integer.valueOf(FinalResult) == 1) {
a2[iTemp1].setBalance(a2[iTemp1].getBalance() + Integer.valueOf(TransferCash));
a2[iTemp].setBalance(a2[iTemp].getBalance() - Integer.valueOf(TransferCash));
break;
}
if (Integer.valueOf(FinalResult) == 2) {
break;
}
}
} else {
System.out.printf("your input must be a POSITIVE number.");
break;
}
} else {
System.out.printf("You dont have enough money.");
break;
}
} else {
System.out.printf("You must input an integer number\n");
break;
}
} else {
System.out.printf("This account is not exist.");
break;
}
} else {
System.out.printf("you must enter an integer number\n");
}
}
}
public void EXIT() throws FileNotFoundException {
sal.Save("F:\\account.txt");
for (i = 0; i < sal.a1; i++) {
sal.output.format("%s %s %d %d %d ", a2[i].getFirstName(), a2[i].getLastName(), a2[i].getAccountNumber(), a2[i].getPassword(), a2[i].getBalance());
}
sal.CloseOutputFile();
Exit = 0;
Exit++;
}
public void Close() {
System.exit(7);
}
}
package atmfile;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Mohammad Ali
*/
import java.io.*;
import java.util.*;
public class SaveAndLoad extends BankOperations {
Scanner input1;
Formatter output;
int k = 0;
int j = 0;
int mod = 0;
int a1 = 0;
int p = 0;
int c = 0;
int l1 = 0;
int f = 0;
int cash[] = new int[1000];
int accountNumber[] = new int[1000];
int password[] = new int[1000];
String temp[] = new String[1000];
String fname[] = new String[1000];
String lname[] = new String[1000];
public SaveAndLoad(String FilePath) throws FileNotFoundException {
try {
File myfile = new File(FilePath);
input1 = new Scanner(myfile);
} catch (FileNotFoundException fne) {
System.out.print("Error1=File not found.");
}
}
public void Load() {
while (input1.hasNext()) {
temp[k] = input1.next();
mod = k % 5;
switch (mod) {
case 0: {
fname[f] = temp[k];
f++;
break;
}
case 1: {
lname[l1] = temp[k];
l1++;
break;
}
case 2: {
accountNumber[a1] = Integer.valueOf(temp[k]);
a1++;
break;
}
case 3: {
password[p] = Integer.valueOf(temp[k]);
p++;
break;
}
case 4: {
cash[c] = Integer.valueOf(temp[k]);
c++;
break;
}
}
k++;
}
}
public void CloseInputFile() {
input1.close();
}
public void Save(String FileName) throws FileNotFoundException {
try {
output = new Formatter(FileName);
System.out.print("BaBye");
} catch (SecurityException se) {
System.out.print("Security Error");
}
}
public void CloseOutputFile() {
output.close();
}
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Post what you have started with and ask specific question.
quuba 81 Posting Pro
When I do not have a file account.txt program gives me stack overflow.
The first use of your program should give the possibility to create new accounts.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.