Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Banka
  8. {
  9.     class Program
  10.     {
  11.         public static List<Account> ListOfAccounts = new List<Account>();
  12.         public static int GlobalCounter = 0;
  13.  
  14.         static void Main(string[] args)
  15.         {
  16.             Console.WriteLine("Welcome to our bank!");
  17.             Console.WriteLine("1 - Make new account");
  18.             Console.WriteLine("2 - Operations");
  19.             Console.WriteLine("3 - Exit");
  20.             while( true )
  21.             {
  22.                 int unos = Convert.ToInt32(Console.ReadLine());
  23.                 if (unos == 3) break;
  24.                 else if( unos==1 )
  25.                 {
  26.                     Console.WriteLine("Name: ");
  27.                     string Name = Console.ReadLine();
  28.                     Console.WriteLine("Adress: ");
  29.                      string Adress = Console.ReadLine();
  30.                     Console.WriteLine("Phone");
  31.                      string Phone = Console.ReadLine();
  32.                     Console.WriteLine("Initial Amont: ");
  33.                      int InitialAmount = Convert.ToInt32(Console.ReadLine());
  34.                     Console.WriteLine("Password: ");
  35.                      string Password = Console.ReadLine();
  36.                     Console.WriteLine("Re-type Password: ");
  37.                      string Password2 = Console.ReadLine();
  38.                      
  39.                     Account a = new Account(Name, Adress, Phone, InitialAmount, Password);
  40.                     ListOfAccounts.Add(a);
  41.                 }
  42.                 else if(unos==2)
  43.                 {
  44.                     Console.WriteLine("Enter your account number:");
  45.                     int RedniBroj;
  46.                     while (true)
  47.                     {
  48.                         RedniBroj = Convert.ToInt32(Console.ReadLine());
  49.                         if (RedniBroj < ListOfAccounts.Count()) break;
  50.                         else
  51.                         {
  52.                             Console.WriteLine("Account number is not valid. Please type again.");
  53.                         }
  54.                     }
  55.                     Console.WriteLine("Enter your password");
  56.                     string Password = Console.ReadLine();
  57.  
  58.        
  59.                     Account a = ListOfAccounts[RedniBroj - 1];
  60.                     bool SucessLogin = true;
  61.                     if(Password != a.Password)
  62.                     {
  63.                         Console.WriteLine("Wrong password. Please try again.");
  64.                          string Password2 = Console.ReadLine();
  65.                         if(a.Password != Password2)
  66.                         {
  67.                             SucessLogin = false;
  68.                             Console.WriteLine("Wrong password. You have one more try:");
  69.                             string Password3 = Console.ReadLine();
  70.                             if (a.Password != Password3)
  71.                             {
  72.                                 "Your account is blocked. You must call the bank imeadiately."
  73.                             }
  74.                             else SucessLogin=true;
  75.                         }
  76.                         else
  77.                         {
  78.                             SucessLogin = true;
  79.                         }
  80.                     }
  81.                     else if (SucessLogin==true )
  82.                     {
  83.                         Console.WriteLine("Select operation to process");
  84.                         Console.WriteLine("1 - Change password");
  85.                         Console.WriteLine("2 - Deposit money");
  86.                         Console.WriteLine("3 - Withdraw money");
  87.                         Console.WriteLine("4 - Print");
  88.                         Console.WriteLine("5 - Exit menu");
  89.                         int Operation = Convert.ToInt32(Console.ReadLine());
  90.                         switch(Operation)
  91.                         {
  92.                             case 1:
  93.                                 while(true)
  94.                                 {
  95.                                     Console.WriteLine("Type your new password");
  96.                                     string NewPassword1 = Console.ReadLine();
  97.                                     Console.WriteLine("Retype your new password");
  98.                                     string NewPassword2 = Console.ReadLine();
  99.                                     if (NewPassword1 != NewPassword2) Console.WriteLine("They do not match.Process will start from beggining")
  100.                                 else
  101.                                     {
  102.                                         a.Password = NewPassword1;
  103.                                         break;
  104.                                     }
  105.                                 }
  106.                                 break;
  107.                             case 2:
  108.                                 Console.WriteLine("Amount: ");
  109.                                 int amount = Convert.ToInt32(Console.ReadLine());
  110.                                 a.Balance += amount;
  111.                                 Console.WriteLine("Operation Successful");
  112.                                 break;
  113.                             case 3:
  114.                                 Console.WriteLine("Amount:");
  115.                                 int amountFIX = Convert.ToInt32(Console.ReadLine());
  116.                                 a.Balance -= amountFIX;
  117.                                 Console.WriteLine("Operation Successful");
  118.                                 break;
  119.                             case 4:
  120.                                 Console.WriteLine("Name: ",a.Name);
  121.                                 Console.WriteLine("Adress: ",a.Adress);
  122.                                 Console.WriteLine("Balance: ", a.Balance, " KM");
  123.                                 Console.WriteLine("Account number: ",RedniBroj );
  124.                                 break;
  125.                             case 5:
  126.                             Console.WriteLine("Good Bye");bool Exit = true;
  127.                             break;
  128.                         }
  129.                     }
  130.                 }
  131.             }
  132.            
  133.         }
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement