0% found this document useful (0 votes)
13 views6 pages

ATm

This document is a C program for an ATM banking system that allows users to check their balance, deposit money, and withdraw money. It includes functions for each operation, a main menu for user interaction, and error handling for invalid inputs. The program runs in a loop, allowing users to perform multiple transactions until they choose to exit.

Uploaded by

tanishq12381123
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)
13 views6 pages

ATm

This document is a C program for an ATM banking system that allows users to check their balance, deposit money, and withdraw money. It includes functions for each operation, a main menu for user interaction, and error handling for invalid inputs. The program runs in a loop, allowing users to perform multiple transactions until they choose to exit.

Uploaded by

tanishq12381123
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
You are on page 1/ 6

#include <stdio.

h>

#include <stdlib.h>

#include <stdbool.h>

#include <math.h>

// Functions

void clearScreen();

void mainMenu();

void checkBalance(float balance);

float moneyDeposit(float balance);

float moneyWithdraw(float balance);

void menuExit();

void errorMessage();

// Main Code

int main() {

int option;

float balance = 15000.00;

int choose;

bool again = true;

while (again) {

mainMenu();

printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");

printf("Your Selection:\t");
scanf("%d", &option);

clearScreen();

switch (option) {

case 1:

checkBalance(balance);

break;

case 2:

balance = moneyDeposit(balance);

break;

case 3:

balance = moneyWithdraw(balance);

break;

case 4:

menuExit();

return 0;

default:

errorMessage();

break;

printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");

printf("Would you like to do another transaction:\n");

printf("< 1 > Yes\n");

printf("< 2 > No\n");


scanf("%d", &choose);

clearScreen();

if (choose == 2) {

again = false;

menuExit();

return 0;

// Functions

void clearScreen() {

#ifdef _WIN32

system("cls");

#else

system("clear");

#endif

void mainMenu() {

printf("****************** Hello! *******************\n");

printf("********** Welcome to ATM Banking ***********\n\n");


printf("**** Please choose one of the options below ****\n\n");

printf("< 1 > Check Balance\n");

printf("< 2 > Deposit\n");

printf("< 3 > Withdraw\n");

printf("< 4 > Exit\n\n");

void checkBalance(float balance) {

printf("You chose to see your balance\n");

printf("\n**** Your Available Balance is: $%.2f\n\n", balance);

float moneyDeposit(float balance) {

float deposit;

printf("You chose to deposit money\n");

printf("$$$$ Your Balance is: $%.2f\n\n", balance);

printf("**** Enter your amount to deposit: ");

scanf("%f", &deposit);

if (deposit <= 0) {

printf("+++ Invalid deposit amount +++\n\n");

} else {

balance += deposit;

printf("\n**** Your New Balance is: $%.2f\n\n", balance);

}
return balance;

float moneyWithdraw(float balance) {

float withdraw;

bool back = true;

printf("You chose to withdraw money\n");

printf("$$$$ Your Balance is: $%.2f\n\n", balance);

while (back) {

printf("Enter your amount to withdraw (0 to cancel): ");

scanf("%f", &withdraw);

if (withdraw == 0) {

printf("Withdrawal cancelled.\n\n");

break;

} else if (withdraw > 0 && withdraw <= balance) {

balance -= withdraw;

printf("\n$$$$ You withdrew: $%.2f\n", withdraw);

printf("**** Your New Balance is: $%.2f\n\n", balance);

back = false;

} else {

printf("+++ Invalid or insufficient amount +++\n");

printf("**** Your Balance is: $%.2f\n\n", balance);

}
}

return balance;

void menuExit() {

printf("-------------- Take your receipt! ------------------\n");

printf("----- Thank you for using ATM Banking Machine! -----\n");

printf("------------- BROUGHT TO YOU BY you! ---------------\n");

void errorMessage() {

printf("+++ !!! You selected an invalid number !!! +++\n");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy