SHARE
TWEET

Untitled

a guest Oct 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'dart:io';
  2.  
  3. double totalBal = 100000;
  4. int id1 = 123;
  5. int id2 = 456;
  6. int passId1 = 111;
  7. int passId2 = 222;
  8.  
  9.  
  10. int userAccount()
  11. {
  12.   int a;
  13.   int b;
  14.   stdout.write("Masukan ID Anda : ");
  15.   a = int.parse(stdin.readLineSync());
  16.   stdout.write("Password : ");
  17.   b = int.parse(stdin.readLineSync());
  18.  
  19.   if(a == id1 && b == passId1 || a == id2 && b == passId2)
  20.   {
  21.     drawMainMenu();
  22.   } else
  23.   {
  24.     print("ID atau Pass Anda Salah: !");
  25.     userAccount();
  26.   }
  27. }
  28.  
  29. void main()
  30. {
  31.   userAccount();
  32.   drawMainMenu();
  33. }
  34.  
  35. void drawMainMenu()
  36. {
  37.   int pilihan;
  38.  
  39.   print("\n-- WELCOME TO ATM MAIN MENU --");
  40.   print("\n1. Melihat Tabungan");
  41.   print("\n2. Menarik Uang");
  42.   print("\n3. Setor Uang");
  43.   print("\n4. Exit");
  44.   stdout.write("\nChoice -> ");
  45.   pilihan = int.parse(stdin.readLineSync());
  46.  
  47.   switch(pilihan)
  48.   {
  49.     case 1 :
  50.       viewAccountInfo();
  51.       break;
  52.     case 2 :
  53.       withDraw();
  54.       break;
  55.     case 3 :
  56.       addFunds();
  57.       break;
  58.     case 4 :
  59.       print("Terima Kasih Sudah Menggunakan ATM");
  60.   }
  61. }
  62.  
  63. void viewAccountInfo()
  64. {
  65.   print("\n-- Informasi Account Anda --");
  66.   print("\t-- Total : Rp. $totalBal");
  67.   drawMainMenu();
  68. }
  69.  
  70. void deposit(int depAmount)
  71. {
  72.   print("\n*** Tolong Masukan Uang Anda Sekarang ***");
  73.   totalBal += depAmount;
  74. }
  75.  
  76. void checkNsf(int withdrawAmount)
  77. {
  78.   if(totalBal - withdrawAmount < 0)
  79.   {
  80.     print("\n*** ERROR!!! Insufficient Funds in Your Account ***");
  81.   } else
  82.   {
  83.     totalBal -= withdrawAmount;
  84.     print("\n*** Tolong Ambil Uang Anda Sekarang ***");
  85.   }
  86. }
  87.  
  88. void addFunds()
  89. {
  90.   int pilihann;
  91.   print("\nMenabung: ");
  92.   print("\n1.- Rp. 20.000");
  93.   print("\n2.- Rp. 50.000");
  94.   print("\n3.- Rp. 100.000");
  95.   print("\n4.- Rp. 1.000.000");
  96.   print("\n5.- Kembali ke Menu");
  97.  
  98.   stdout.write("\nChoice -> ");
  99.   pilihann = int.parse(stdin.readLineSync());
  100.  
  101.   switch(pilihann)
  102.   {
  103.     case 1 :
  104.       deposit(20000);
  105.       drawMainMenu();
  106.       break;
  107.    
  108.     case 2 :
  109.       deposit(50000);
  110.       drawMainMenu();
  111.       break;
  112.  
  113.     case 3 :
  114.       deposit(100000);
  115.       drawMainMenu();
  116.       break;
  117.  
  118.     case 4 :
  119.       deposit(1000000);
  120.       drawMainMenu();
  121.       break;
  122.  
  123.     case 5 :
  124.       drawMainMenu();
  125.       break;
  126.   }
  127. }
  128.  
  129. void withDraw()
  130. {
  131.   int pilihann;
  132.   print("\nMenarik Uang: ");
  133.   print("\n1.- Rp. 20.000");
  134.   print("\n2.- Rp. 50.000");
  135.   print("\n3.- Rp. 100.000");
  136.   print("\n4.- Rp. 1.000.000");
  137.   print("\n5.- Kembali ke Menu");
  138.  
  139.   stdout.write("\nChoice -> ");
  140.   pilihann = int.parse(stdin.readLineSync());
  141.  
  142.   switch(pilihann)
  143.   {
  144.     case 1 :
  145.       checkNsf(20000);
  146.       drawMainMenu();
  147.       break;
  148.    
  149.     case 2 :
  150.       checkNsf(50000);
  151.       drawMainMenu();
  152.       break;
  153.  
  154.     case 3 :
  155.       checkNsf(100000);
  156.       drawMainMenu();
  157.       break;
  158.  
  159.     case 4 :
  160.       checkNsf(1000000);
  161.       drawMainMenu();
  162.       break;
  163.  
  164.     case 5 :
  165.       drawMainMenu();
  166.       break;
  167.   }
  168. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top