My below code is not working as designed. It appears that my if condition works but the loops inside this condition are not adhering to the if condition ~ skipped if you will. The first two while loops are skipped despite the conditional statements. The third loop is processed no matter what. I get the desired output via pointer but the while loop is designed to check for if a number entered is invalid. Please help as I do not know why this is invalid.
/*Withdraw a prompted amount of money from selected account type via * account_balance pointer*/
void Withdraw(double *account_balancePtr, char account_type)
{
double withdraw;
double *balance_holder = account_balancePtr;
printf("Enter WITHDRAWAL amount: $");
scanf("%lf", &withdraw);
if (account_type == "C")
{
while (withdraw > *balance_holder)
{
printf("Insufficient Withdrawal Amount. Please withdrawal no more than checking balance of %.2lf.", *balance_holder);
printf("Enter WITHDRAWAL amount: $");
scanf("%lf", &withdraw);
}
*account_balancePtr = *balance_holder - withdraw;
}
else if (account_type == "S")
{
while (withdraw > *balance_holder)
{
printf("Insufficient Withdrawal Amount. Please withdrawal no more than savings balance of %.2lf.", *balance_holder);
printf("Enter WITHDRAWAL amount: $");
scanf("%lf", &withdraw);
}
*account_balancePtr = *balance_holder - withdraw;
}
else
{
while (withdraw > (abs(MAXCREDIT) + *balance_holder))
{
printf("Insufficient Withdrawal Amount. Please withdrawal no more than maximum avaiable credit of %.2lf.", (abs(MAXCREDIT) + *balance_holder));
printf("Enter WITHDRAWAL amount: $");
scanf("%lf", &withdraw);
}
*account_balancePtr = *balance_holder - withdraw;
}
}