Skip to content

Instantly share code, notes, and snippets.

@isu3ru
Forked from Thilini5678/gist:aaf81dc1abefd9ded167bc5752fe45d5
Last active March 21, 2021 16:12
Show Gist options
  • Save isu3ru/05793e97cc1d012c8d8f417b6020dfc1 to your computer and use it in GitHub Desktop.
Save isu3ru/05793e97cc1d012c8d8f417b6020dfc1 to your computer and use it in GitHub Desktop.
ATM
import java.util.*;
public class Atm {
public static void main(String arg[]) {
int pasward = 1234;
double amount = 5674.25;
Scanner sc = new Scanner(System.in);
System.out.println("\tWelcome To ABC Bank");
System.out.println();
for (int x = 1; x < 4; x++) {
System.out.print("Plase Enter Your PIN : ");
int userPin = sc.nextInt();
if (userPin == pasward) {
System.out.println("\t\nLoggin Succesfull");
for (int y = 1; y < 4; y++) {
System.out.print("\nPlease Enter The Amount : ");
double userAmount = sc.nextDouble();
if (userAmount <= amount) {
System.out.println("\nCollect Your Cash Rs :" + userAmount);
amount -= userAmount;
System.out.println("\nYour Balance Is Rs : " + amount);
break;
} else {
if (y == 3) {
System.out.println("Not Sufficient Balance\n\nYour Balance Is Rs : " + amount + "\n\tCard Rejected");
break;
} else {
System.out.print("Not Sufficient Balance\nYour Balance Is Rs : " + amount + "\n\tTry Again");
}
}
}
break;
} else {
if (x == 3) {
System.out.println("Wrong Pin\n\tYour Account Is Blocked\n\tContact The Bank");
break;
} else {
System.out.println("\tWrong Pin & Try Again");
}
}
}
System.out.println("\t\nHave A Nice Day");
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment