C 这是计算账户余额的正确公式吗?当我运行代码时,我的最终余额是错误的

C 这是计算账户余额的正确公式吗?当我运行代码时,我的最终余额是错误的,c,calculator,C,Calculator,这就是我目前所拥有的。我有更多的工作要添加,但我认为现在,平衡计算器世界的工作。我是新手,但我做得更好。(我想)。我没有正确的方程式吗 此代码的目标是在输入取款和存款后显示您的最终余额。出于某种原因,我的最终平衡总是我的起始平衡 // // main.c // accountbalance // // // #include <stdio.h> int main() { float deposit[5]; float withdrawal[5];

这就是我目前所拥有的。我有更多的工作要添加,但我认为现在,平衡计算器世界的工作。我是新手,但我做得更好。(我想)。我没有正确的方程式吗

此代码的目标是在输入取款和存款后显示您的最终余额。出于某种原因,我的最终平衡总是我的起始平衡

//
//  main.c
//  accountbalance
//
// 
//

#include <stdio.h>

int main()
{
    
    float deposit[5];
    float withdrawal[5];
    float Curr_balance;
    float Final_Bal;
    
    int NumDep;
    int NumWit;
    
    printf("Welcome to the Computer Banking System!");
    printf("\n\nEnter your current balance in dollars and cents: ");
    scanf ("%f", &Curr_balance);
    
        while (Curr_balance <0){
            printf("\nBeginning balance must be at least zero, please re-enter.");
            scanf ("%f", &Curr_balance);
    }
   
    printf ("\n\nEnter the number of deposits (0-5): ");
    scanf ("%d", &NumDep);
        while (NumDep > 5 || NumDep < 0){
            printf ("Sorry, invalid number of deposits entered. Please try again");
            scanf("%d", &NumDep);
    }
    
    printf ("\n\nEnter the number of withdrawals (0-5): ");
    scanf ("%d", &NumWit);
        while (NumWit > 5 || NumWit < 0){
            printf ("Sorry, invalid number of withdrawals entered. Please try again");
            scanf("%d", &NumWit);
    }
    
    int i;
        for (i=0; i<NumDep; i++){
            printf ("\n\nEnter the amount of deposit #%d: ", i+1);
            scanf("%f", &deposit[i]);
           
           if (deposit[i] <0)
           {
               printf ("Sorry, invalid number of deposits entered. Please try again ");
               i = i -1;
               continue;
           }
       }
    int h;
        for (h=0; h<NumWit; h++){
        
            printf ("Enter the amount of withdrawal #%d: ", i+1);
            scanf ("%f",&withdrawal[h]);
        
        if (withdrawal[i]<0){
            printf ("Withdrawal amount must be greater than zero, please try again");
            i--;
            continue;
        }
        else
    {
        
    }
        
        
    }
    
    
    Final_Bal = Curr_balance - NumDep + NumWit;
    printf ("The closing balance is $%.2f", Curr_balance);
        
    
    
    
        
    
    return 0;
}
//
//main.c
//账户余额
//
// 
//
#包括
int main()
{
浮动存款[5];
浮动提款[5];
浮动货币余额;
浮动最终余额;
int NumDep;
int NumWit;
printf(“欢迎使用计算机银行系统!”);
printf(“\n\n以美元和美分输入当前余额:”;
scanf(“%f”和当前余额);
而(当前余额5 | | NumDep<0){
printf(“对不起,输入的存款数量无效,请重试”);
scanf(“%d”&NumDep);
}
printf(“\n\n输入取款次数(0-5):”;
scanf(“%d”&NumWit);
而(NumWit>5 | | NumWit<0){
printf(“对不起,输入的取款数量无效。请重试”);
scanf(“%d”&NumWit);
}
int i;

对于(i=0;我在哪里使用
存款
取款
?另外,
现金余额
NumDep
的单位是什么?他们同意吗?我读到的只是最后两行代码(在
返回0之前;
)。您计算
最终余额
,然后打印
当前余额
。您只需阅读自己的代码(口头,大声)并问问自己这是否有意义。除了计算
final\u Bal
的最终公式中的错误之外,您检查取款输入金额是否也有错误的条件。您正在扫描
取款[h]
并检查
取款[i]
。哇!我犯了很多错误。我相信我现在走上了正确的道路!谢谢大家!