473,499 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Atm machine program in C

6 New Member
Hello everyone I am a student who is in big trouble. I have a ATM machine program that i need to write in C but the problem is that my teacher wants us to use file IO and he didnt teach us how to use it. below is my program. I am desperately begging for help.


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {
  5.    char  option,pin,transaction;
  6.    int deposit, withdraw;
  7.    option='0';
  8.  
  9.  
  10.  
  11.     printf("WELCOME TO SAMUEL'S BANK\n");
  12.     printf("------------------------------\n\n");
  13.     printf("Main Menu\n");
  14.     printf("------------------------------\n");
  15.     printf("1)Enter Pin #\n");
  16.     printf("2)Exit\n");
  17.     printf("------------------------------\n\n");
  18.     scanf("%c", &option);
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.         {
  26.             system ("cls");
  27.             printf("Pin Number Verification\n");
  28.             printf("------------------------------\n\n");
  29.             printf("Please enter your pin number: ");
  30.             scanf("%s", &pin);
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.             //if(inputfile ==NULL)
  39.             {
  40.                 printf("Unable to open input file\n");
  41.             }
  42.             return 1;
  43.  
  44.  
  45.             system ("cls");    
  46.             printf("Transactions\n");
  47.             printf("------------------------------\n");
  48.             printf("1)Deposit\n2)Withdraw\n3)Statement\n4)Exit\n");
  49.             printf("------------------------------\n");
  50.             scanf("%s",&transaction);
  51.         }
  52.  
  53.  
  54.  
  55.  
  56.                     if (transaction =='1')
  57.  
  58.                         {
  59.                             system ("cls");
  60.                             printf("Deposit\n");
  61.                             printf("------------------------------\n\n");
  62.                             printf("Please enter the amount of money you would like to deposit: ");
  63.                             scanf("%d", &deposit);
  64.                     }
  65.  
  66.                     if (transaction =='2')
  67.  
  68.                         {
  69.                             system ("cls");
  70.                             printf("Withdraw\n");
  71.                             printf("------------------------------\n\n");
  72.                             printf("Please enter the amount of money you would like to withdraw: ");
  73.                             scanf("%d", &withdraw);
  74.                         }
  75.  
  76.                     if (transaction=='3')
  77.  
  78.                         {
  79.                             system ("cls");
  80.                             printf("Statement\n");
  81.                             printf("------------------------------\n\n");
  82.                         }
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. return 0;
  91.  
  92.  
  93. }
Nov 30 '08 #1
8 27879
gpraghuram
1,275 Recognized Expert Top Contributor
But what help u need?
File IO means you want to get the input/ouput from a file instead of STDIO?

Raghu
Dec 1 '08 #2
techking
6 New Member
Yes sir but the problem is hat i do not konw how to use file io so i wanted to get help with it.
Dec 1 '08 #3
techking
6 New Member
I was not properly thought how to use file io so i wanted help with it becaue we have to use arrays with teh file io too.
Dec 1 '08 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
Are you able to get this working using arrays?

Next write a function to load your arrays. Pass in the array addresses and have the function install hard-coded values.

Next, get the program working. You just call the function to load the hard-coded values into the arrays.

After the program is working, replace the guts of the funciton with logic that reads a disc file and stores the data in the arrays.
Dec 1 '08 #5
techking
6 New Member
Hey first of all i would like to thank you for responding. I would like to ask you if you had an example of arrays because i wasnt properly thought on how to use it.
Dec 2 '08 #6
weaknessforcats
9,208 Recognized Expert Moderator Expert
There is an article named Arrays Revealed in the C/C++ HowTos that containes exactly what you want.

Unfortunuately, due to a recent site upgrade the HowTos are not working right now.

I tried to attach it to this post but it is too large.
Dec 2 '08 #7
weaknessforcats
9,208 Recognized Expert Moderator Expert
Wouldn't you know that five minutes after I said the articel on arrays in unavailable, I found it.

Here it is: http://bytes.com/insights/c/772412-arrays-revealed.
Dec 2 '08 #8
techking
6 New Member
Thank you so much. You are a real life saver.
Dec 2 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2645
by: Adrian Parker | last post by:
I wrote a VB program on my Windows XP machine. It does multi table queries, you can add/delete and edit records, it all worked very beautifully. I was very careful to validate data, and on my...
3
2743
by: John | last post by:
Hello, I need to know which programs are opn on another machine in my network, these programs are opened from a shared drive on the server. How can I do this ? I've already dowloaded a sample...
4
1477
by: Denise Mills | last post by:
Hi, On my previous Windows 98 machine, I wrote a simple C program that takes two text files as input, performs some calculations, then produces a text file that contains the results. It worked...
3
8136
by: Nidhee Pathak via .NET 247 | last post by:
Hi, I am trying to run an exe present on the remote machine using the ManagementClass object. I connect to the remote machine using ObjectManagementScope class, but i am not being able to run the...
6
1905
by: Michael | last post by:
I am running an application that requires "Full Trust" which is declared in the assembly. How do I trap for the System.Security.Policy.PolicyException that is raised by a local machines CAS if...
0
6021
by: joestevens232 | last post by:
I am seriously stuck and have been working on this for hours and hours and can't figure out my next step....heres the program assignment. This vending machine dispenses 1. M&Ms ($.65), 2. Chips...
4
8296
by: erxuan | last post by:
Hi, I'm calling zlib.dll to compress/uncompress file in my C# program. The problem is it works very well on my 32-bit machine, but on another 64-bit machine, it throw an exception says "An attempt...
4
9803
by: queenma7 | last post by:
Write a program that simulates a soft drink machine. The program should use a structure that stores the following information: Drink name Drink cost Number of drinks in machine The...
5
2545
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
41
2638
by: c | last post by:
Hi every one, Me and my Cousin were talking about C and C#, I love C and he loves C#..and were talking C is ...blah blah...C# is Blah Blah ...etc and then we decided to write a program that...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.