0

hey please could you help me out i have a problem with this code the normal cash is taking me to the transfer

#include <stdio.h> 
#include <conio.h> 

void main() 
{ 
char x,ch1,y,Y; 
int pin=12345, account=12591,account1, choice; 
int fcash, famount;
//char login[10]=’joeliwain’
int withdraw, deposit, transfer, amount; 
printf(":--------------------------------------:\n"); 
printf(": Welcome to ATM Banking System:\n"); 
//printf("Enter login name:  ");
//scanf(“%s”, login1);
printf(": Enter your PIN -->:\t"); 
scanf(" %d",&pin); 
printf("\n--------------------------------------:\n"); 
if (pin==12345) 
{printf("access granted");} 
else 
Loop: 
printf("------------------------\n");
printf("\t Main Menu\n");
printf("------------------------\n");
printf("1.Withdraw Cash\n");
printf("2.Cash Transfer\n");
printf("3.Deposit cash\n");
printf("4.Display Balance\n");
printf("5.Exit\n");
printf("------------------------\n");
printf("Enter your choice: ");
scanf("%d",&choice);
printf("\n\n"); 
switch(choice) 
{ 
case 1:
{
		if(amount==0)
{
printf("You have an Insufficient Funds\nPress Enter"); 
goto Loop; 
} 	//end of if()
else if(amount!=0)
{
printf("1.  Fast Cash\n");
printf("2.  Normal Cash\n");
printf("Please Select a mode of withdrawal: ");
scanf("%d",&withdraw);
if(withdraw==1)
{
printf("1----500\n");
printf("2----1000 \n");
printf("3----2000 \n");
printf("4----5000 \n");
printf("5----10000 \n");
printf("6----15000 \n");
printf("7----20000 \n");
printf("------------------------\n");
printf("Select one of the denominations of money: ");
scanf("%d",&fcash);
if(fcash==1)
{
	 	famount=500;
		amount=amount-famount;
}		//End of if() function
else if(fcash==2)
{ famount=1000;
amount=amount-famount;
}
else if(fcash==3)
{ famount=2000;
amount=amount-famount;
}
else if(fcash==4)
{ famount=5000;
amount=amount-famount;
}
else if(fcash==5)
{ famount=10000;
amount=amount-famount;
}
else if(fcash==6)
{ famount=15000;
amount=amount-famount;
}
else if(fcash==7)
{ famount=20000;
amount=amount-famount;
}
printf("\n Are you sure you want to withdraw kshs. %d [y/n]:  ",famount);
getchar();
scanf("%c",&x);
if((x =='y')||(x=='Y')) 
{
			printf("\n Cash Successfully Withdrawn! \n");
       	printf("Do you wish to print a receipt  [y/n] :    ");
scanf("%c",&ch1);
			if(ch1=='y')
			{
			printf("\n Account#15\n");
			printf("Widrawn is %d", famount);
			printf("\nBalance is %d",amount);
			}	//if() ends
			else if(ch1!='y')
			{
				printf("\n OK, Have a Nice Day \n");
			}	//end of if()
} 		//End of if()
else if ((x =='n')||(x=='N')) 
{
			printf("Good Bye and Have A Nice Day \n");
}		//End of if()
{
//else
{
printf("enter the amount %d to withdraw",amount=100000);
scanf("%d",&withdraw);
printf("Cash successfully withdrawn %d",amount-withdraw);
printf("do you wish to print a receipt [y/n]:   ");
scanf("%c",&ch1);
if(ch1=='y')
			{
			printf("\n Account#15\n");
			printf("withdraw is %d", withdraw);
			printf("\nBalance is %d",amount);
}
			}	//if() ends
//if(withdraw==2)
{ 
printf("Your Balance %d\n\n",amount); 
printf("Enter Amount to Withdraw: "); 
scanf("%d",&withdraw); 
amount = amount - withdraw; 
printf("\nYour Current Balance %d\n\n",amount); 
printf("Do you wish to print a receipt  [y/n] :  ");
scanf("%c",&ch1);
		if(ch1=='y')
		{
			printf("\n Account#15\n");
			printf("Withdrawn is %d", withdraw);
			printf("\nBalance is %d",amount);
		}	//if() ends
		else if(ch1!='y')
		{
			printf("\n OK, Have a Nice Day \n");
		}	//end of if()
printf("\nThank You for Banking With Us"); 
} 	//end of if()
} 	//end of outer if()
break;
}
} 

case 2:
{

            printf("\n Enter Amount to Transfer in multiples of 500:  ");
scanf(" %d",&transfer); 
            printf("\n Enter the account no. to which you want to transfer:  ");
            scanf("%d",& account);
	printf("\n This account is held by Usman Ismail, if this information is correct please re-enter the account number :  ");
	getchar();
scanf("%d",&account1);
if(account==account1)
{
		printf("\nTransaction Confirmed. \n");
	       	amount = amount - transfer;
	       	printf("\nYour Current Balance %d",amount=1000000-transfer); 
printf("Do you wish to print a receipt [y/n]:  ");
getchar();
		scanf("%c",&ch1);		
		if(ch1=='y')
		{
			printf("\n Account#15 \n");
printf("\n Amount Transferred  is %d",transfer);
printf("\n Balance is : %d ",amount);
}
if(ch1!='y')
{
			printf("\n Ok, Good Bye.. \n");
		   }	//End of if()
}
else if(account!= account1)
{
printf("Error: account number do not match \n");
}
break;
} 

case 3:
{
printf("Your Balance %d\n",amount=100000); 
printf("\nEnter Amount to Deposit: "); 
scanf("%d",&deposit); 
amount= amount + deposit; 
printf("\nYour Current Balance %d\n",amount);
printf("Do you wish to print a receipt.. [y/n]:   ");
getchar();
scanf("%c",&ch1);
if(ch1=='y')
{
printf("\n Account#15  \n");
printf("Deposited cash is: %d",deposit );
printf("\n Balance is: %d ",amount);
}
if(ch1!='y')
{
printf("OK, Good Bye \n");
}
 	printf("\n\nThank You for Banking With Us"); 
break;
} 

case 4:
{
printf("Your current balance %d\n\n",amount=100000);
printf("Do you wish to print a receipt  [y/n] :    ");
getchar();
scanf("%c",&ch1);
	if(ch1=='y')
	{
		printf("\n Account#15\n");
		printf("\nBalance is %d",amount);
	}	//if() ends
	else if(ch1!='y')
	{
		printf("\n OK, Have a Nice Day \n");
	}	//end of if()
 	printf("Another transaction? y or n?: "); 
scanf(" %c",&x); 
if((x == 'y')||(x== 'Y')) 
{ 
    	 	 goto Loop; 
} 
else if((x =='n')||(x== 'N')) 
{ 
printf("\nThank You for Banking With Us"); 
 	} 
break;
} 

case 5:
{
printf("\n\nThank You Come Again"); 
printf("\n Have a Good Day \n");
break;
} 	// End of case 5

default: 
printf("\n Error: Enter a valid option \n");
}	//End of switch case

printf("\n Thanx...");
getch();	
}	//exit();

};

thanks

2
Contributors
1
Reply
6
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.