Write a complete C program that functions as a bank account

Write a complete C program that functions as a bank account simulator, lie sure to be complete and thorough, keeping in mind all of the syntax details and program flow ideas we have discussed this semester Please he sure to include comments in your program as mentioned in the grading rubric, and please remember to demonstrate your working code to your instructor before you submit this program for grading. Your program should accomplish the following objectives: When starting the program, it should ask the user for the starting balance of the account, the annual percentage rate (APR) of interest earned for the account and the date the account is created This information should be recorded in the transaction log (discussed below). Once the account is set up, the program should present a user with a menu giving five possible options. You can decide how the user selects which option should be performed next but your program should only accept valid inputs from the menu. The program should return to this menu repeatedly until the last option is selected. The five menu options are detailed next: The user should be able to make a deposit to the account. Selecting this option should prompt the user to enter the amount of the deposit (make sure it is valid), which should then be added to the account balance. This should be recorded in the transaction log. The user should be able to make a withdrawal from the account. Selecting this option should prompt the user to enter the amount of the withdrawal (make sure it is valid), which should be subtracted from the account balance. This should be recorded in the transaction log. Do not allow the user to withdrawal more money than is in the account under any circumstances!!! (You can decide exactly how your program handles this, Docs it refuse to do the transaction? Does it allow the user to pull out the current balance in the account, leaving a balance of zero? Up to you to decide.) The user should be able to calculate interest earned on the account, using the formula provided below. Any interest earned should be deposited back into the account. This should be recorded in the transaction log. Only apply interest if the account balance starts out bigger than zero! Interest = Balance Times (APR as a decimal) The user should be able to apply a fee to the account. Selecting this option should prompt the user for the amount of the fee (make sure it is valid), which should be subtracted from the account balance. This should be recorded in the transaction log. A negative account balance can result from this option! The user should be able to close the account. When this happens, ask the user for the date the account is being closed. The closing date and the closing balance should be written to the transaction log as well as a \"Thank you for your business\" message. At this time, the program should end. Your program should create a transaction log of everything happening to the account from its creation to its end. Write this transaction log into an output file called \"xactlog.txt\" while your program is running. You are allowed some freedom in style and formatting with this log, but make sure to meet the minimum requirements for each transaction.

Solution

#include <stdio.h>

int main(){
   float balance;
   float annualPercentageRate;
   int day,month,year;
   printf(\"Enter the following details:\ \");
   printf(\"Starting balance: \");
   scanf(\"%f\",&balance);
   printf(\"Annual Percentage Rate: \");
   scanf(\"%f\",&annualPercentageRate);
   printf(\"Date in format DD/MM/YYYY: \");
   scanf(\"%d/%d/%d\",&day,&month,&year);

   FILE* fid = fopen(\"xactlog.txt\",\"w\");
   fprintf( fid, \"Starting Balance: %f\ \", balance);
   fprintf( fid, \"Annual Percentage Rate: %f\ \", annualPercentageRate);
   fprintf( fid, \"Date: %d/%d/%d\ \", day, month, year );

   char action;
   scanf(\"%c\",&action);
   while(1){
       printf(\"Select an option:\ D for making a deposit, W for withdrawing from the account, \");
       printf(\"I for displaying Interest Rate Earned, F for applying a fee and C for closing the account\ \");
       scanf(\"%c\", &action );

       if( action == \'D\' ){
           float deposit;
           printf(\"Enter the amount to deposit: \");
           scanf(\"%f\",&deposit);
           balance += deposit;
           fprintf(fid, \"Deposit %f in the account : Success\ \", deposit);
       }
       else if( action == \'W\' ){
           float withdrawl;
           printf(\"Enter the amount you want to withdraw: \");
           scanf(\"%f\",&withdrawl);
           if( balance < withdrawl ){
               printf(\"Can\'t do the transaction due to insufficient balance\ \");
               fprintf(fid, \"Withdrawing %f from the account: Failed\ \", withdrawl);      
           }
           else{
               balance -= withdrawl;
               fprintf(fid, \"Withdrawing %f from the account: Success\ \", withdrawl);      
           }      
       }
       else if( action == \'I\' ){
           balance += balance*(annualPercentageRate/100);
           fprintf(fid, \"Adding %f interest to the account: Success\ \", balance*annualPercentageRate);      
       }
       else if( action == \'F\' ){
           float fee;
           printf(\"Enter the fee amount: \");
           scanf(\"%f\",&fee);
           balance -= fee;
           fprintf(fid, \"Applied %f fee to the account: Success\ \", fee);      
       }
       else if( action == \'C\' ){
           printf(\"Enter the closing date in format DD/MM/YYYY\ \");
           scanf(\"%d/%d/%d\", &day,&month,&year);

           fprintf(fid, \"Closing Date: %d/%d/%d\ \", day, month, year );
           fprintf(fid, \"Closing Balance: %f\ \", balance );
           fprintf(fid, \"Thank you for your business\ \");
           break;
       }
       scanf(\"%c\", &action );
   }
   fclose(fid);
   return 0;
}

 Write a complete C program that functions as a bank account simulator, lie sure to be complete and thorough, keeping in mind all of the syntax details and prog
 Write a complete C program that functions as a bank account simulator, lie sure to be complete and thorough, keeping in mind all of the syntax details and prog

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site