Skip to content

Instantly share code, notes, and snippets.

@Thilini5678
Created March 21, 2021 15:13
Show Gist options
  • Save Thilini5678/aaf81dc1abefd9ded167bc5752fe45d5 to your computer and use it in GitHub Desktop.
Save Thilini5678/aaf81dc1abefd9ded167bc5752fe45d5 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");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment