Thread: i need to write an atm program

  1. #1
    Registered User
    Join Date
    Dec 2016
    Posts
    3

    i need to write an atm program

    hello everyone i am kind of in trouble with my programming assingment my instructor wants an atm program. i actually wrote some code about that but i can't move it more i need your help guys. these are my codes. if you gave me some ideas that would be awesome. thanks.

  2. #2
    Registered User
    Join Date
    Dec 2016
    Posts
    3
    Code:
    #include <stdio.h>
    //************************************************************************************************//
    //**********************************************DISPLAY MENU*************************************//
    //**********************************************************************************************//
    
    
    
    
    void atm(int accountno, double account_balance  )
    {
    	int choice=1;
    	double amount=0;
    	double iterator=0;
    	
    	while(choice!=0){
    	  printf("Hello %d what would you like to do today?\n", accountno); 
    	  printf("1 for Account Balance\n");
    	  printf("2 for Cash Deposit\n");
    	  printf("3 for Cash Withdrawal\n");
    	  printf("0 for Exit\n"); 
    	  printf("Please make your selection >> \n");
    	  scanf("%d",&choice);
    	//******************************************************************//  
    	  if(choice==1){
    	  	printf("Your account balance is %.2lf\n\n\n",account_balance);
    	  }
        //*****************************************************************//
    	  
    	  
    	  else if(choice==2)
    	  {
    	  	printf("Enter your deposit amount: ");
    	  	scanf("%lf",&amount);
    	  	
    	  	
    	  	
    		  if(valid_deposit(amount))
    		  {
    	  		account_balance+=amount;
    		}
    		else
    		{
    			printf("Error:Invalid Deposit Amount!\n\n\n");
    		}
        	  
    	  
    	  }
    	  
    	  //********************************************************************//
    	  
    	  else if(choice==3)
    	  {
    	  	printf("Enter your withdraw amount:  ");
    	  	scanf("%lf" ,&amount);
    	  	
    		  
    		  
    		  if(valid_withdrawal(account_balance,amount))
    	  	{
    	  		
    	  		account_balance-=amount;
    	  		given_money(amount);
    		  }
    	  	
    	 	else
    	  	{
    	  		printf("Error: Invalid Withdraw Amount!\n\n\n");
    		}
    	  }
    	 //**********************************************************************//
    	  //*********************************************************************//
    	   
    	  else printf("Error:Invalid Choice!\n\n\n");
    	}
    }
    //****************************************************************************//
    //****************************************************************************//
    
    
    
    
    //************************************************************************************************//
    //**************************************FIND ACCOUNT FUNCTION************************************//
    //**********************************************************************************************//
    
    
    int find_account(int accountNums[] , int acctNum , int numAccts)
    {
    	if(accountNums[0]==acctNum||accountNums[1] == acctNum)	return 1;
    	return -1;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    //**********************************ACCOUNT NAME****************************************//
    
    
    char accountNames[100] = {"CS111" ,"MUHAMMET"};
    
    
    if(accountNames=='CS111' ||  accountNames=='MUHAMMET' )
    
    
    {
    	printf("Finding account %d returns %d\n", CS111, find_account(accountNames,CS111,2));
        printf("Finding account %d returns %d\n", MUHAMMET, find_account(accountNames,MUHAMMET,2));
    return 1;
    
    
    }
    else
    return -1;
    
    
    
    
    }
    //************************************************************************************//
    //************************************LOGIN FUNCTION**********************************//
    //***********************************************************************************//
    int login(int accountNums[],char *accountNames[100],char *accountPins[],double accountBalance[],int numAccts);
    {	int accountNum;
    	char *PIN;
    	printf("Please enter your account number.");
    	scanf("%d", &accountNum);
    	
    	if(find_account(accountNums[],accountNum,numAccts)==1){
    	
    	printf("Please enter your pin:");
    	gets(PIN);
    	
    	if(strcmp(PIN,"0111")==0 || strcmp("9876",PIN)==0)
    	{
    		atm (accountNames[],accountBalance[]);
    	}
    		else
    		printf("Pin not correct.");
    	}
    	else printf("Account is not found");
    	
    }
    //**********************************************************************************//
    //*******************************MAIN FUNCTION*************************************//
    //********************************************************************************//
    int main()
    {
    	int accountNums [2] = {12345,67890};
    	char *accountNames [100] = {"CS111", "MUHAMMET"};
    	char *accountPins [2] = { "01111", "98765"};
    	double accountBalance [2] = 10000.00,250.00;
    	login(accountNums,accountNames,accountPins,accountBalance,2);
    
    
    }

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    What exactly are you having trouble with? Are you getting compiler errors and/or warnings? Is the code not working as expect (and if so, how)?

    The code you posted is C, did you mean to post on the C++ board?

  4. #4
    Registered User
    Join Date
    Dec 2016
    Posts
    3
    it is c# but i compile it in c++. i have compiler errors. but i have no idea how to fix them.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    C# and C++ are completely different languages. This looks like cobbled-together C code from various sources with a few errors sprinkled in.

    How about you post your error messages.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 09-09-2014, 08:23 AM
  2. can u write this program for me please
    By Amay Bhumak in forum C Programming
    Replies: 10
    Last Post: 07-31-2013, 11:25 PM
  3. trying to write a tic, tac, toe program
    By jason007thomas in forum C Programming
    Replies: 5
    Last Post: 09-01-2010, 10:54 AM
  4. Write program that uses MS-DOS?
    By Cgrasshopper in forum C Programming
    Replies: 5
    Last Post: 06-22-2010, 11:48 PM
  5. Anyone help me write this program better?
    By VegasSte in forum C Programming
    Replies: 2
    Last Post: 11-27-2002, 11:42 AM

Tags for this Thread