Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Matlab script that functions as a hank account simulator. Be su

ID: 3775628 • Letter: W

Question

Write a complete Matlab script that functions as a hank account simulator. Be sure to be complete and thorough, keeping in mind all of the syntax details and program flow ideas we have discussed this semester. Please be 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 script 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 repeated 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 he 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. Does 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 hack 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 dale live 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.

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>

int main()
{
   double totalAmount;
   double apr;
   char opening_date[10];
   FILE *fptr;
   fptr = fopen("xactlog.txt", "w");
   if(fptr == NULL)
    {
printf("Error! Unable to log open the file.");
exit(1);
    }
   // gets(sentence);
   
   printf("%s", "Please enter the initial amount : ");       //Enter the initial amount
   scanf("%lf", &totalAmount);
   printf("%s", "Please enter the Annual Percentage Rate(APR) : ");
   scanf("%lf", &apr);
   printf("%s", "Please enter the account opening date in the format dd/MM/yyyy: ");
   scanf("%s", opening_date);
   fprintf(fptr,"Your Account is opened with an amount of $ %lf and APR %lf on %s. ",totalAmount, apr ,opening_date);
   apr/=100;   //Convert % into fraction. eg : 30% to .3
   int isActive = 1;
   int choosen_option;
   while(isActive){   //While account is not closed ask the options
       printf("%s", "Please choose your choice : 1-->To deposit 2-->To withdraw 3-->Calculate interest 4-->Apply Fee 5-->Close Account : ");
       scanf("%d", &choosen_option);
       switch(choosen_option){
           case 1:{
               double deposit_amount;
               printf("%s", "Choose the amount : ");
               scanf("%lf", &deposit_amount);
               if(deposit_amount > 0) {
                   totalAmount += deposit_amount;
                   fprintf(fptr,"$ %lf has been deposited into your account. ", deposit_amount);
               } else{
                   printf("%s ", "You entered invalid amount. Your transaction has been cancelled. Please try again.");
               }
               break;
           } case 2:{
               double withdrawal_amount;
               printf("%s", "Choose the amount to be withdrawn: ");
               scanf("%lf", &withdrawal_amount);
               if(totalAmount - withdrawal_amount >= 0) {
                   totalAmount -= withdrawal_amount;
                   fprintf(fptr,"$ %lf has been withdrawn from your account ", withdrawal_amount);
               } else{
                   printf("%s %lf", "You entered invalid amount. Amount should not exceed your total amount i.e ",totalAmount);
               }
               break;
           } case 3:{
               if(totalAmount > 0){
                   double interest = totalAmount * apr;
                   totalAmount += interest;
                   fprintf(fptr,"$ %lf interest has been added to your account. Resulting sum is : $ %lf ", interest, totalAmount);
               } else{
                   printf("%s ", "There is no amount to Calculate interest. ");
               }
               break;
           } case 4:{
               double fee;
               printf("%s", "Choose the fee : ");
               scanf("%lf", &fee);
               if(fee >= 0) {
                   totalAmount -= fee;
                   fprintf(fptr,"$ %lf has been withdrawn. ", fee);
               } else{
                   printf("%s ", "You entered invalid amount. Your transaction hass been cancelled. ");
               }
               break;
           } case 5:{
               char closing_date[10];
               printf("Please enter the date of closing of your account in the format dd/MM/yyyy: ");
               scanf("%s",closing_date);
               fprintf(fptr,"Your account has been closed on %s with the amount $ %lf ",closing_date , totalAmount);
               printf("Thank you for having a business with us. ");
               isActive = 0;
               break;
           } default :{
               printf("You entered an invalid option. ");
           }
       }
   }
   fclose(fptr);   //Close the file stream.
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote