Monday, July 30, 2012
Aplikasi java - ATM sederhana
Posted by
Unknown
at
4:31 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package menuatm;
import java.util.Scanner;
public class Menuatm {
public static void main(String[] args) {
int pil, saldo = 50000, nabung, ambil, temp;
while (true) {
Scanner sc = new Scanner(System.in);
System.out.println("\n1.Cek Saldo");
System.out.println("2.Simpan Uang");
System.out.println("3.Ambil Uang");
System.out.println("4.Keluar");
System.out.print("\nPilih Menu : ");
pil = sc.nextInt();
switch (pil) {
case 1:
System.out.println("Saldo Anda adalah Rp. " + saldo);
break;
case 2:
System.out.print("Masukan Jumlah Uang yang anda simpan Rp.");
nabung = sc.nextInt();
saldo += nabung;
System.out.println("Saldo Anda adalah Rp. " + saldo);
break;
case 3:
System.out.print("Masukan Jumlah Uang yang anda Ambil Rp.");
ambil = sc.nextInt();
temp = saldo; //temp diisi saldo
temp -= ambil;
if (temp <= 50000) {
System.out.println("Saldo Minimal setelah pengambilan harus Rp.50000");
} else {
saldo -= ambil;
System.out.println("Saldo Anda adalah Rp. " + saldo);
}
break;
case 4:
System.exit(0);
break;
default:
System.exit(0);
break;
}
}
}
}
Subscribe to:
Post Comments (Atom)