Atm machine program in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • techking
    New Member
    • Nov 2008
    • 6

    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.


    Code:
    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
       char  option,pin,transaction;
       int deposit, withdraw;
       option='0';
       
       
       
        printf("WELCOME TO SAMUEL'S BANK\n");
    	printf("------------------------------\n\n");
    	printf("Main Menu\n");
    	printf("------------------------------\n");
    	printf("1)Enter Pin #\n");
    	printf("2)Exit\n");
    	printf("------------------------------\n\n");
    	scanf("%c", &option);
        
    
    
    
    
    		
    		{
                system ("cls");
    			printf("Pin Number Verification\n");
    			printf("------------------------------\n\n");
    			printf("Please enter your pin number: ");
    			scanf("%s", &pin);
    		
    		
    		
    		
    
    			
    			
    			//if(inputfile ==NULL)
    			{
    				printf("Unable to open input file\n");
    			}
    			return 1;
    
    
    			system ("cls");	
    	    	printf("Transactions\n");
    	    	printf("------------------------------\n");
    	    	printf("1)Deposit\n2)Withdraw\n3)Statement\n4)Exit\n");
    	    	printf("------------------------------\n");
    			scanf("%s",&transaction);
    		}
    			
    			
    		
    			
    					if (transaction =='1')
    						
    						{
    						    system ("cls");
    							printf("Deposit\n");
    							printf("------------------------------\n\n");
    							printf("Please enter the amount of money you would like to deposit: ");
    							scanf("%d", &deposit);
    					}
    
    					if (transaction =='2')
    					
    						{
    							system ("cls");
    							printf("Withdraw\n");
    							printf("------------------------------\n\n");
    							printf("Please enter the amount of money you would like to withdraw: ");
    							scanf("%d", &withdraw);
    						}
    
    					if (transaction=='3')
    
    						{
    							system ("cls");
    							printf("Statement\n");
    							printf("------------------------------\n\n");
    						}
    
    
    
    		
    			
    
    
    return 0;
    
    
    }
    Last edited by Niheel; Oct 13 '11, 06:16 AM. Reason: code tags
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    But what help u need?
    File IO means you want to get the input/ouput from a file instead of STDIO?

    Raghu

    Comment

    • techking
      New Member
      • Nov 2008
      • 6

      #3
      Yes sir but the problem is hat i do not konw how to use file io so i wanted to get help with it.

      Comment

      • techking
        New Member
        • Nov 2008
        • 6

        #4
        file io

        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.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          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.

          Comment

          • techking
            New Member
            • Nov 2008
            • 6

            #6
            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.

            Comment

            • weaknessforcats
              Recognized Expert Expert
              • Mar 2007
              • 9214

              #7
              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.

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                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.

                Comment

                • techking
                  New Member
                  • Nov 2008
                  • 6

                  #9
                  Thank you so much. You are a real life saver.

                  Comment

                  Working...