473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Atm machine program in C

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 27866
gpraghuram
1,275 Expert 1GB
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
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
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 Expert Mod 8TB
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
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 Expert Mod 8TB
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 Expert Mod 8TB
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
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
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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
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...

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.