-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.cpp
More file actions
75 lines (65 loc) · 1.85 KB
/
ATM.cpp
File metadata and controls
75 lines (65 loc) · 1.85 KB
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
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
char option;
int main(){
float money = 1000;
printf ("Hi! Welcome to your ATM. How can we help you? ");
do{
char choice;
cout << "\nSelect an option: " << "\n" << "\t" << "*Deposit (D)" << "\n\t" << "*Withdraw (W)" << "\n\t" <<"*Check Balance (C)" << "\n";
cin >> choice;
//Operación de deposito
if(choice == 'D'){
printf("\nYou have selected: Deposit");
float deposit;
cout << "\n" << "Enter the amount to deposit: ";
cin >> deposit;
float balance = money + deposit;
money = balance;
printf("\nIts current balance is: $%.2f", balance);
}
//Operación de retiro
if(choice == 'W'){
printf("\nYou have selected: Withdraw");
float retreat;
cout << "\n" << "Enter the amount to withdraw: ";
cin >> retreat;
float balance = (money - retreat);
money = balance;
printf("\nYou have withdrawn: $%.2f \nIts current balance is: $%.2f", retreat, balance);
if(balance <= 50.00 & balance > 00.00){
printf("\tWarning: Your balance is low");
}
if(balance == 0.00){
printf("\t|Insufficient balance|");
}
if(balance < 0.00){
printf("\t|Negative balance|");
}
}
//Consultar saldo
if(choice == 'C'){
printf("\n\nYou have selected: Consult balance");
printf("\nIts current balance is: $%.2f", money);
if(money < 50.00 & money > 00.00){
printf("\tWarning: Your balance is low");
if(money == 0.00){
printf("\t|Insufficient balance|");
}
if(money < 0.00){
printf("\t|Negative balance|");
}
}
}
do{
printf("\nYou wish to perform another operation? (Y/N): ");
scanf("%s",& option);
}while(option != 'Y' && option != 'N');
}while(option == 'Y');
if(option == 'N'){
printf("\n\tThank you for your preference. Come back soon!");
}
return 0;
}