473,880 Members | 1,716 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 27914
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
2673
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 machine it works very well. I compiled it, and sent the executable, which works fine on my machine, to a business elsewhere. They also have a Windows XP machine. When they run my executable, using the same database I use, the program opens and...
3
2761
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 program form vbnet.mvps.org but it doesn't work?? Greets John
4
1493
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 fine on that machine. Recently, however, I obtained a new Windows XP machine, and the program is not working correctly on my new computer computer. On the new XP machine, I'm running the program in the DOS window, as before, and the program does...
3
8158
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 exe through normal Win32 process. How should I go about it? -------------------------------- From: Nidhee Pathak ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>s3QhesQMJ0O24aiIcMmT+w==</Id>
6
1921
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 its current policy will not allow "Full Trust", ie its running in the Intranet Zone. I am trying to trap the error to advise users to have adm revise policy to permit running the program otherwise a cryptic debug screen is raised.
0
6092
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 ($1.16), 3. Peppermint gum ($.28). Your program should prompt the user to deposit money (i.e. the user needs to type in the amount deposited at the prompt), select the product, and provide change. Change should be provided in quarters, dimes, and ...
4
8311
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 was made to load a program with an incorrect format. <Exception from HRESULT: 0x8007000B>" when uncompress() is called. Since I have the source code of Zlib, I can build and generate both ..lib and .dll files. The generated .lib file works...
4
9846
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 program should create an array of five structures. The elements should be initialized with the following data: Drink Name Cost Number in Machine
5
2566
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 use to run a UM program, I kept on getting error messages. I have used someone else's implementation and it runs fine. I have compared my code with other's and I still can't figure it out what's wrong with mine. So please help me out, after 3...
41
2725
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 will calculate the factorial of 10, 10 millions time and print the reusult in a file with the name log.txt.. I wrote something like this
0
9926
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11093
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10811
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9550
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7951
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5973
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3220
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.