float money,money1,balance,balance1;
int deposite1,withdraw,deposite;
int password,choice;
char answer;
printf("Assumed your money for example\n");
scanf("%f",&money1);
money=money1;
printf("Your money is RM%.2f\n",money);
printf("********************************\n");
printf(" Welcome to BankRupted\n\n\n");
printf("********************************\n");
printf("\nPlease enter your password:\n");
scanf("%f",&password);
printf("Your password is valid!!\n");
do
{
printf("________________________________\n");
printf(" 1.Check your balance\n");
printf(" 2.Deposite\n");
printf(" 3.Withdraw\n");
printf("________________________________\n");
printf("Please enter your choice:\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
printf("Your balance :RM%.2f\n", money);
break;
case 2 :
printf("You can only deposite note RM10, RM50 and RM100\n");
printf("Enter the amount of money to be deposite:\n");
scanf("%d",&deposite1);
deposite=deposite1/10;
printf("Your had deposite :RM10 x %d\n", deposite);
balance1=deposite1+money1;
printf("Your balance is :RM%.2f\n", balance1);
break;
case 3:
printf("Enter the amount of money to be withdraw:\n");
scanf("%d",&withdraw);
printf("Your amount is :RM%d\n", withdraw);
balance=money1-withdraw;
printf("Your balance is :RM%.2f\n", balance);
break;
}
}
printf("Do you want to continue(y=Yes/n=No)?\n");
scanf("%c", &answer);
}
while (answer=='y'||answer=='Y');{
printf("________________________________\n");
printf("Thank You for using our services\n");
printf("Please come again\n");
printf("********************************\n");
return 0;
}
}
The buffer is not empty when you call scanf("%c", &answer);
You can clear it by using getchar(); just before the scanf. However, you should really consider using c++ style i/o functions in general. http://www.cplusplus.com/doc/tutorial/basic_io.html
I adjusted your code.
You should definetely properly indent your code, otherwise it's unreadable.
Next time, do something like this, so you know where your int, do and while, etc , all end.
I also commented out the second part of kbw's comment. Where you ask if the user wants to continue. It's under the do loop, so the compiler expects to see a while.
And where do you define the password for the user anyway?
#include<stdio.h>
int main()
{
float money,money1,balance,balance1;
int deposite1,withdraw,deposite;
int password,choice;
char answer;
printf("Assumed your money for example\n");
scanf("%f",&money1);
money=money1;
printf("Your money is RM%.2f\n",money);
printf("********************************\n");
printf(" Welcome to BankRupted\n\n\n");
printf("********************************\n");
printf("\nPlease enter your password:\n");
scanf("%f",&password);
printf("Your password is valid!!\n");
do
{
printf("________________________________\n");
printf(" 1.Check your balance\n");
printf(" 2.Deposite\n");
printf(" 3.Withdraw\n");
printf("________________________________\n");
printf("Please enter your choice:\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
printf("Your balance :RM%.2f\n", money);
break;
}
case 2 :
{
printf("You can only deposite note RM10, RM50 and RM100\n");
printf("Enter the amount of money to be deposite:\n");
scanf("%d",&deposite1);
deposite=deposite1/10;
printf("Your had deposite :RM10 x %d\n", deposite);
balance1=deposite1+money1;
printf("Your balance is :RM%.2f\n", balance1);
break;
}
case 3:
{
printf("Enter the amount of money to be withdraw:\n");
scanf("%d",&withdraw);
printf("Your amount is :RM%d\n", withdraw);
balance=money1-withdraw;
printf("Your balance is :RM%.2f\n", balance);
break;
}
} // end of switch
} // end of do
// error: expected 'while' before "printf" and then code blocks { }
printf("Do you want to continue(y=Yes/n=No)?\n");
scanf("%c", &answer);
}while (answer=='y'||answer=='Y');
{
printf("________________________________\n");
printf("Thank You for using our services\n");
printf("Please come again\n");
printf("********************************\n");
return 0;
}
}