programme c pour un simple distributeur automatique de billets à l'aide de if et else if

Je ne suis pas en mesure de savoir où est l'erreur. Lorsque j'essaie d'exécuter le programme, Sa ne va pas passer le choix et va directement à la fin du programme, après avoir demandé pour le choix. Et, c'est aussi de donner un avertissement à "Montrer la sortie à partir de construire" dans le compilateur visual c++. Quelqu'un peut-il m'aider, s'il vous plaît?

     #include <stdio.h>
     int main ()
     {
     int card_number, choice, withdraw, deposit;
     float amount = 3000.00, new_amount = 0;
     char password;
     printf("Enter the card number: ");
     scanf("%d", &card_number);
     printf("Enter the Password: ");
     scanf(" %c", &password);
     printf("\n\n");
     printf("\n\t***********************************");
     printf("\n\t*           MENU                  *");
     printf("\n\t*     1. Check Balance            *");
     printf("\n\t*     2. Withdraw                 *");
     printf("\n\t*     3. Deposit                  *");
     printf("\n\t*     4. Exit                     *");
     printf("\n\t*                                 *");
     printf("\n\t***********************************");
     printf("\n\n");
     printf("Enter your choice: ");
     scanf("%d", &choice);

     if (choice == 1)
       {
      printf("Current balance on your account: %f\n", amount);
       }
     else if (choice == 2)
      {
    printf("Enter the amount you want to withdraw: ");
    scanf("%d", &withdraw);

    if (withdraw > amount)
      {
        printf("You don't have sufficient balance");
      }
    else
      {
        new_amount = amount - withdraw;
        printf("Current balance on your account: %f\n", new_amount);
      }
}

else if (choice == 3)
{
    printf("Enter the amount you want to deposit: ");
    scanf("%d", &deposit);
    amount = amount + deposit;
    printf("Current balance on your account: %d\n", amount);
}
else if (choice == 4)
{
    printf("Thank you for using our service\n\n");
}

return 0;
    }
  • j'ai essayé votre code, et sa semble bien pour moi. essayez de déboguer(f10)
InformationsquelleAutor anansharm | 2013-10-18