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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/* Usandfriend's ATM Code */
#include <stdio.h>
#include <strlib.h>
#include "simpio.h"
#include "genlib.h"
main()
{
int what_user_wants,dep,wit,exit;
float totaldeposit,totalwithdrawal,balance;
string password,name,phonenumber,address,accountnumber,newname,newphonenumber,newaddress,newpassword;
totaldeposit=0;
totalwithdrawal=0;
dep=0;
wit=0;
balance=5000;
password="21b";
name="John Bloke";
phonenumber="1-234-567-8910";
address="Street, City, State, Zip Code, United States";
accountnumber="32a10dhd3h";
printf ("***************************************ATM*************************************\n\n");
PASSWORD:
printf ("Enter Password.\n\n > ");
newpassword=GetLine();
printf ("\n");
if (StringEqual(newpassword,password)==TRUE)
{
printf ("Unlocked.\n\n\n");
goto begin;
}
else {
printf ("Retry.\n\n");
goto PASSWORD;
}
begin:
printf ("Enter the option number you need.\n");
printf ("1. Withdraw from Balance.\n");
printf ("2. Deposit.\n");
printf ("3. Balance Inquiry.\n");
printf ("4. Last 5 Transactions.\n");
printf ("5. Edit Personal Information.\n");
printf ("6. Exit.\n\n > ");
what_user_wants=GetInteger();
switch (what_user_wants)
{
case 1: goto WithdrawBalance;break;
case 2: goto DepositBalance;break;
case 3: goto BalanceInquiry;break;
case 4: goto PrintLast5Inquiry;break;
case 5: goto EditInformation;break;
case 6: goto Exit;break;
default: printf ("Please retry.\n\n");goto begin;break;
}
WithdrawBalance:
double withdraw;
wit++;
printf ("How much money would you like to withdraw? ");
withdraw=GetReal();
totalwithdrawal=withdraw+totalwithdrawal;
balance=balance-withdraw;
printf ("New balance is %.2f.\n\n",balance);
goto begin;
DepositBalance:
double deposit;
dep++;
printf ("How much money would you like to deposit? ");
deposit=GetReal();
totaldeposit=totaldeposit+deposit;
balance=balance+deposit;
printf ("New balance is %.2f.\n\n",balance);
goto begin;
BalanceInquiry:
printf ("Total balance: %.2f.\n\n",balance);
goto begin;
PrintLast5Inquiry:
printf ("Total withdrawals: %.2f.\n",totalwithdrawal);
printf ("Total deposits: %.2f.\n\n",totaldeposit);
goto begin;
EditInformation:
printf ("Your current information is:\n");
printf (" Name: %s\n",name);
printf (" Phone Number: %s\n",phonenumber);
printf (" Address: %s\n",address);
printf (" Account Number: %s\n\n",accountnumber);
begin123:
printf ("Enter choice number.\n");
printf ("1. Change Information.\n");
printf ("2. Continue.\n\n > ");
what_user_wants=GetInteger();
switch (what_user_wants)
{
case 1: goto ChangeInformation;break;
case 2: goto begin;break;
default: printf ("Please retry.\n");goto begin123;break;
}
goto begin;
ChangeInformation:
printf ("Enter new name or enter \"NULL\" to keep same name.\n\n > ");
newname=GetLine();
printf ("\n");
if (StringEqual(newname,"NULL")==TRUE)
{
name=name;
}
else {
name=newname;
}
printf ("Enter new phone number or enter \"NULL\" to keep same number.\n\n > ");
newphonenumber=GetLine();
printf ("\n");
if (StringEqual(newphonenumber,"NULL")==TRUE)
{
phonenumber=phonenumber;
}
else {
phonenumber=newphonenumber;
}
printf ("Enter new address or enter \"NULL\" to keep the same address.\n\n > ");
newaddress=GetLine();
printf ("\n");
if (StringEqual(newaddress,"NULL")==TRUE)
{
address=address;
}
else {
address=newaddress;
}
goto begin;
Exit:
printf ("Are you sure you want to exit? Enter 1 to exit or 2 to stay.\n");
exit=GetInteger();
switch (exit)
{
case 1: goto hi;break;
case 2: goto begin;break;
default: printf ("Please retry.\n");goto Exit;break;
}
hi:;
}
|