0% found this document useful (0 votes)
5 views4 pages

Java ATM Simulation Program

This Java program simulates a basic ATM banking system where users can check their balance, withdraw cash, deposit cash, and transfer funds. It prompts users for their ATM PIN and provides options based on successful authentication. The program includes validation for transaction amounts and formats currency for display.

Uploaded by

abiyuraka04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Java ATM Simulation Program

This Java program simulates a basic ATM banking system where users can check their balance, withdraw cash, deposit cash, and transfer funds. It prompts users for their ATM PIN and provides options based on successful authentication. The program includes validation for transaction amounts and formats currency for display.

Uploaded by

abiyuraka04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

DecimalFormat;
import [Link];

public class bank {


public static void main(String[] args) {
Scanner raka = new Scanner([Link]);
DecimalFormat mata_uang = new DecimalFormat("#,##0.00");

String pin_atm, menu = "", pecahan, bang, no_rek = "", nm_pemilik = "",
kode_bang = "", nm_bang = "";
int saldo = 500000;
int tarik = 0, setor = 0, teef = 0, biaya_teef = 6500;

// variabel tambahan untuk struk


int nominal_tarik = 0, nominal_setor = 0, nominal_tf = 0;
String tujuan_rek = "", tujuan_nama = "", tujuan_bank = "", tujuan_kode
= "";

[Link]("----> BANK CRUD <----");


[Link]("Masukkan PIN ATM anda (6 digit): ");
pin_atm = [Link]();

if (pin_atm.equals("822009")) {
[Link]("1. ceksaldo"
+ "\n2. tariktunai"
+ "\n3. setortunai"
+ "\n4. transfer"
+ "\nSilahkan pilih menu: ");
menu = [Link]();

switch (menu) {
case "ceksaldo":
menu = "Cek saldo";
break;

case "tariktunai":
menu = "Tarik tunai";
[Link]("---> Tarik tunai <---"
+ "\n1. 50.000"
+ "\n2. 100.000"
+ "\nSilahkan pilih pecahan: ");
pecahan = [Link]();
if ([Link]("1") || [Link]("50000")) {
[Link]("Pecahan 50"
+ "\nMasukan nominal tarik: Rp ");
tarik = [Link]();
if (tarik % 50000 == 0 && (saldo - tarik) >= 50000) {
saldo -= tarik;
nominal_tarik = tarik;
} else if (tarik % 50000 != 0) {
[Link]("Maaf, bukan pecahan 50K");
} else {
[Link]("Maaf, anda melebihi minimum sisa
saldo");
}
} else if ([Link]("2") || [Link]("100000"))
{
[Link]("Pecahan 100"
+ "\nMasukan nominal tarik: Rp ");
tarik = [Link]();
if (tarik % 100000 == 0 && (saldo - tarik) >= 100000) {
saldo -= tarik;
nominal_tarik = tarik;
} else if (tarik % 100000 != 0) {
[Link]("Maaf, bukan pecahan 100K");
} else {
[Link]("Maaf, anda melebihi minimum sisa
saldo");
}
}
break;

case "setortunai":
menu = "Setor tunai";
[Link]("---> Setor tunai <---"
+ "\n1. 50.000"
+ "\n2. 100.000"
+ "\nSilahkan pilih pecahan: ");
pecahan = [Link]();
if ([Link]("1") || [Link]("50000")) {
[Link]("Pecahan 50"
+ "\nMasukan nominal setor: Rp ");
setor = [Link]();
if (setor % 50000 == 0) {
saldo += setor;
nominal_setor = setor;
} else {
[Link]("Maaf, bukan pecahan 50K");
}
} else if ([Link]("2") || [Link]("100000"))
{
[Link]("Pecahan 100"
+ "\nMasukan nominal setor: Rp ");
setor = [Link]();
if (setor % 100000 == 0) {
saldo += setor;
nominal_setor = setor;
} else {
[Link]("Maaf, bukan pecahan 100K");
}
}
break;

case "transfer":
menu = "Transfer";
[Link]("---> TRANSFER <---"
+ "\n1. Sesama bang"
+ "\n2. Beda bang"
+ "\nMasukkan pilihan bang: ");
bang = [Link]();

if ([Link]("sesama") || [Link]("1")) {
[Link]("TF Sesama"
+ "\nMasukan no rek tujuan: ");
no_rek = [Link]();
[Link]("Masukkan nama pemilik: ");
nm_pemilik = [Link]();
[Link]("Masukan nominal tf: Rp ");
teef = [Link]();
if (teef >= 10000) {
saldo -= teef;
nominal_tf = teef;
tujuan_rek = no_rek;
tujuan_nama = nm_pemilik;
} else {
[Link]("Maaf, minimal tf 10k buoss!!!");
}
} else if ([Link]("beda") ||
[Link]("2")) {
[Link]("TF Beda"
+ "\n1. bang boger (008)"
+ "\n2. bang gift alok (014)"
+ "\nMasukan kode bang tujuan: ");
kode_bang = [Link]();

if (kode_bang.equals("008")) {
nm_bang = "Bang boger";
tujuan_kode = "008";
} else if (kode_bang.equals("014")) {
nm_bang = "Bang gift alok";
tujuan_kode = "014";
} else {
[Link]("Maaf kode yang anda masukkan
salah!");
break;
}

tujuan_bank = nm_bang;
[Link]("\nMasukan no rek tujuan: ");
no_rek = [Link]();
[Link]("Masukkan nama pemilik: ");
nm_pemilik = [Link]();
[Link]("Masukan nominal tf: Rp ");
teef = [Link]();
if (teef >= 10000) {
saldo -= teef + biaya_teef;
nominal_tf = teef;
tujuan_rek = no_rek;
tujuan_nama = nm_pemilik;
} else {
[Link]("Maaf, minimal tf 10k buoss!!!");
}
}
break;
}

// CETAK STRUK
[Link]("\n---> STROKE TRANSAKSI <---");
[Link]("Menu\t\t: " + menu);

if ([Link]("Tarik tunai")) {
[Link]("Nominal tarik\t: Rp " +
mata_uang.format(nominal_tarik));
[Link]("Sisa saldo\t: Rp " +
mata_uang.format(saldo));
} else if ([Link]("Setor tunai")) {
[Link]("Nominal setor\t: Rp " +
mata_uang.format(nominal_setor));
[Link]("Sisa saldo\t: Rp " +
mata_uang.format(saldo));
} else if ([Link]("Transfer")) {
if (!tujuan_bank.equals("")) { // beda bank
[Link]("Kode Bank\t: " + tujuan_kode);
[Link]("Nama Bank\t: " + tujuan_bank);
}
[Link]("No Rek Tujuan\t: " + tujuan_rek);
[Link]("Nama Pemilik\t: " + tujuan_nama);
[Link]("Nominal Transfer: Rp " +
mata_uang.format(nominal_tf));
if (!tujuan_bank.equals("")) { // jika beda bank
[Link]("Biaya Transfer\t: Rp " +
mata_uang.format(biaya_teef));
}
[Link]("Sisa saldo\t: Rp " +
mata_uang.format(saldo));
} else if ([Link]("Cek saldo")) {
[Link]("Sisa saldo\t: Rp " +
mata_uang.format(saldo));
}

} else {
[Link]("Maaf, pin anda salah!");
}
}
}

You might also like