C PROGRAMLAMA DİLİ – ATM MAKİNESİ UYGULAMASI
C dilinde uygulama nasıl yapılır ? C programlama dili atm makinesi kodları nasıldır ? C dilinde uygulama aşamaları nelerdir ? Bu ve benzeri soruların yanıtı ve final niteliğinde serimizin son yazısı olan Atm Makinesi Uygulaması kodlarına bir bakalım.
Başlayalım.
C DİLİ İLE ATM MAKİNESİ UYGULAMASI
Kod bloğu yapısı ve açıklamalar ;
Balance enquiry : Bakiye sorgulama
Cash Withdraw : Para Çekme
Deposit Cash : Para Yatırma/Ödeme
Exit : Çıkış
Kod Bloğu :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #include <stdio.h>//ATM simulator using C program int ATM_Transaction();//Prototype of the functions int anotherTransaction,amountToWidthdraw,amountToDeposit,pin;//Global variable double balance = 1000; // Global variable, Initial balance to be 1000 for everyone int main() { printf("******** Welcome to XYZ bank ******** \n"); printf(" Enter your pin number please: \n"); scanf("%d",&pin); if(pin != 1234) { printf("Sorry your pin is wrong, Pls try again with the card"); } else { ATM_Transaction(); // function call } } int ATM_Transaction() { int choice; printf("Enter any option to be served!\n\n"); printf("1. Balance Enquiry \n"); printf("2. Cash Withdraw\n"); printf("3. Deposit Cash\n"); printf("4. Exit \n"); scanf("%d", &choice); switch(choice) { case 1: // BALANCE Enquiry printf("Your bank balance is: %f", balance); printf("\n\nDo you want to perform another transaction?\nPress 1 to proceed and 2 to exit\n\n"); // request for another transaction scanf("%d",&anotherTransaction); if(anotherTransaction == 1) { ATM_Transaction();// call our transaction method here } break; case 2:// Second option should be withdraw printf("Please enter amount to withdraw: "); scanf("%d", &amountToWidthdraw); if(amountToWidthdraw <= balance) //bal = 1000 { printf("Pls collect your cash\n"); balance=balance-amountToWidthdraw;// printf("Your available balance is %lf\n",balance); printf("\n\nDo you want to perform another transaction?\n Press 1 to proceed and 2 to exit\n\n"); scanf("%d", &anotherTransaction); if(anotherTransaction == 1) { ATM_Transaction(); // call our ATM_Transaction method here } } else { printf("Sorry in-sufficient funds in your account"); printf("\n\nDo you want to perform another transaction?\n Press 1 to proceed and 2 to exit\n\n"); scanf("%d", &anotherTransaction); if(anotherTransaction == 1) { ATM_Transaction(); // call our ATM_Transaction method here } } break; case 3:// DEPOSIT printf("Please enter amount to deposit: "); scanf("%d", &amountToDeposit); balance = amountToDeposit + balance; //600+500 printf("Thank you for depositing, your new balance is: %f", balance); printf("\n\nDo you want another transaction?\nPress 1 to proceed and 2 to exit\n\n");// request for another transaction scanf("%d", &anotherTransaction); if(anotherTransaction == 1) { ATM_Transaction(); // call our transaction method here } break; default: printf("Thanks for Using ATM services, See you soon"); } } |
Yukarda C dili ile yazılmış bir atm makinesi uygulamasını görmektesiniz.
Burada şimdiye kadar yazdığımız serinin içeriklerinin hemen hepsinin kullanımını da görebilirsiniz.
Yukarda bulunan kod bloklarını Code Block programına yapıştırarak program çıktılarını kontrol edin ve bazı koşulları değiştirerek tekrar deneyin.
C PROGRAMLAMA ÖRNEKLERLE ÖĞREN – ATM UYGULAMASI
C programlama örneklerle öğren – ATM Uygulaması adlı yazımızın sonuna geldik.Umuyorum sizler için faydalı bir yazı olmuştur.Bizi takipte kalın,
İyi çalışmalar