Menu

[solved]-Write C Program Allows User Make Simple Banking Transactions Program First Prompt User Ent Q39053895

Write a C program that allows the user to make some simplebanking transactions. The program should first prompt the user toenter the current balance of his/her bank account (in dollars andcents, not less than zero). The program should then prompt the userto enter the number of withdrawals to make, and then the number ofdeposits to make. For this assignment, let’s set a maximum of 5deposits and 5 withdrawals, you’ll see why as you read on. Using aloop, the program should then prompt the user to enter the amountof the first deposit (a positive amount to add to the bank accountbalance), the amount of the second deposit, the third, etc., untilthe number of deposits have been processed. Using a second loop,the program should then prompt the user to enter the amount of thefirst withdrawal (a positive amount to subtract from the bankaccount balance, if possible), the amount of the second withdrawal,the third, etc. until the number of withdrawals have beenprocessed. Once all deposits and withdrawals have been made, theprogram should output the ending balance. The dialog with the usershould look like the following: Welcome to the Computer BankingSystem Enter your current balance in dollars and cents: 256.40Enter the number of deposits (0 – 5): 3 Enter the number ofwithdrawals (0 – 5): 2 Enter the amount of deposit #1: 10.50 Enterthe amount of deposit #2: 12.25 Enter the amount of deposit #3:125.30 Enter the amount of withdrawal #1: 120.35 Enter the amountof withdrawal #2: 35.60 *** The closing balance is $248.50 *** Theprogram should also output one of the following messages based onthe closing balance. That is:  If the closing balance is greaterthan or equal to 50000.00, output: “*** It is time to invest somemoney! ***”  If the closing balance is between 15000.00 and49999.99, output: “*** Maybe you should consider a CD. ***”  Ifthe closing balance is between 1000.00 and 14999.99, output: “***Keep up the good work! ***”  If the closing balance is between0.00 and 999.99, output: “*** Your balance is getting low! ***” So,in the above example, the last line of sample output would be: ***Your balance is getting low! *** Regarding error checking on alluser input, the following 5 error checks (on user input) should beincluded in your program: 1. Ensure that the starting (current)balance is a positive number. If not, the following error messageshould be displayed: *** Beginning balance must be at least zero,please re-enter. 2. Ensure that the number of deposits is between 0and 5. If not, the following error message should be displayed: ***Invalid number of deposits, please re-enter. 3. Ensure that thenumber of withdrawals is between 0 and 5. If not, the followingerror message should be displayed: *** Invalid number ofwithdrawals, please re-enter. 4. Ensure that the deposit amount isequal to or greater than zero. If not, the following error messageshould be displayed: *** Deposit amount must be greater than zero,please re-enter. 5. Ensure that the withdrawal amount does notexceed the current balance (including the new deposits). If so, thefollowing error message should be displayed: *** Withdrawal amountexceeds current balance.

#include
int main () {
   
   /*Variable Declaration */
/*…………………….*/
  
   int number_of_deposits = 0, i;
   int number_of_withdrawls = 0;
   float current_balance;
   float amount_of_deposit[5];
   float amount_of_withdrawls[5];
   float sum = 0 ;
   float closing_balance ;
  
/*Output initial greeting */
   /*————————-*/
  
   printf(“Welcome to the Computer Banking Systemnn”);
     
   /* Prompt user for current balance in dollars andcents */
   /* Ensure that begining balance must be at leastzero.
If not, issue error message and re-prompt. */
  
   do
   {
   printf (“Enter your current balance in dollars andcents:n”);
   scanf (“%f”, ¤t_balance);
   if (current_balance < 0){
   printf(“Beginning balance must be at least zero,please re-entern”);
   }
   }while (current_balance < 0);
   /*End of Loop*/
  
   do
   {
   /*Promote user the number of deposits */
   /* Ensure that the number of deposits is between 0 and5. */
   /* If not, issue error message and re-prompt. */
   printf (“Enter the number of deposits (0 – 5): n”);
   scanf (“%i”, &num_of_deposits);
   if ( number_of_deposits < 0 || number_of_deposits> 5)
   }
   printf (” Invalid number of deposits, pleasere-enter.”);
   }
   } while ( number_of_deposits < 0 ||number_of_deposits > 5); /* End of Loop */
  
   /*Promote user the number of withdrawals */
   /* Ensure that the number of withdrawals is between 0and 5. */
   /* If not, issue error message and re-prompt. */
   printf (“Enter the number of withdrawals(0 – 5): n”);
   scanf (“%i”, &number_of_withdrawls );
   if ( number_of_withdrawls < 0 ||number_of_withdrawls > 5)
   else
   break
   {
   printf (” Invalid number of deposits, pleasere-enter.”); }
   }
   } while ( number_of_withdrawls< 0 ||number_of_withdrawls> 5); /* End of Loop */
  
   /* Ensure that the deposit amount is equal to orgreater than zero. If not, the
following error message should be displayed*/
  
   for( i = 0; i < amount_of_deposit; i++)
   {
   do
   {
   printf(“Enter the amount of deposit #%i: “, i +1);
   scanf (%f, &amount_of_deposits[i]);
   if (amount_of_deposit[i] <== 0)
   printf (“Deposit amount must be greater than zero,please re-enter. n”);
   else
   sum += number_of_deposits[i]
   /*…………………………*/
   }while (deposit[i] <== 0);
   } /* end for loop */
   /*………………..block comments……….*/
   /…………………………*/
  
   for( i = 0; i < amount_of_withdrawl ; i++)
   {
   do
   {
   printf(“Enter the amount of withdrawl #%i: “, i +1);
   scanf (%f, &amount_of_withdrawl[i]);
   if (amount_of_withdrawl[i] < 0 ||amount_of_withdrawls[i] > closing_balance)
   printf (” Withdrawal amount exceeds current balance,please re-enter. n”);
   else
   sum -= amount_of_withdrawls
   }while (amount_of_withdrawl[i] < 0 ||amount_of_withdrawls[i] > ending_balance);
   } /* end for loop */
   printf ( The closing balance is $%0.2f n”,ending_balance);
   /* 0.2 refers to instruction for the computer to print2 digit after the
   decimal point.*/
  
   /* Output appropriate message based on thebalance*/
  /*………………………………………….*/
  
if(closing balance >= 50000.00){
   printf(” It is time to invest some money!n”); /*printing outputs */   
   }   
   else if (closing_balance >= 15000.00 &&closing_balance >= 49999.99 ){ /* Notice the space between elseand if*/
   printf(” Maybe you should consider a CD. n”);  
   }   
   else if (closing_balance >= 1000.00 &&closing_balance <= 14999.99 ){
   printf(” Keep up the good work! n”);  
   }
   else if (closing_balance >= 0.00 && average<= 999.99 ){
   printf(“Your balance is getting low!n”);  
   }   
   /*Display of the following bank statement*/
  
   printf (” Bank Statement n”)
   print {“Starting Balance:$ %.2fnn”,current_balance);
   for ( i= 0; < number_of_deposit i++)
   {
   printf(“Deposit #%d :$%.2fn”,i++,number_of_deposit[i]);
}
printf(“n”);
for(i = 0; i < number_of_withdrawal; i++)
{
printf(“Withdrawal #%d :$%.2fn”,i++,amount_of_withdrawls[i]);
}
printf(“n”);
printf(“Ending balance :$%.2fn”,ending_balance);
printf(“n”);
getch();

I keeping on getting error of un-terminated constant.Someoneplease help me on what i am doing wrong.

}
  
  
  
  

Expert Answer


Answer to Write a C program that allows the user to make some simple banking transactions. The program should first prompt the use… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *