This is what i have below for the Project above but i get a

This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix the error codes im completley lost on what alot of them mean! Please and Thank you! Supposed to be in C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

struct bank
{

   int accNumber;
   string Fname, Lname;
   float balance;
};
static int j = 0;
struct bank B[5];
void read_from_file(const char* filename)
{

   FILE *fp;
   char *word[50];
   int i, flag = 0, count = 0;
   for (i = 0; i<50; i++)
       word[i] = (char *)malloc(20);
   i = 0;
   fp = fopen(filename, \"r\");
   while (fscanf(fp, \"%s\", word[i++]) != EOF){
       count++;
       if (count == 4){
           B[j].accNumber = atoi(word[0]);
           B[j].Fname = word[1];
           B[j].Lname = word[2];
           B[j].balance = atof(word[3]);

           j++;
           i = 0;
           count = 0;
       }
   }
   for (i = 0; i<j; i++)
       cout << B[i].accNumber << \" \" << B[i].Fname << \" \" << B[i].Lname << \" \" << B[i].balance << \"\ \";
   fclose(fp);
}
int addAccount()
{

   int accNum;
   string fname, lname;
   float balance;
   cout << \" --- Provide details ---\ \";
   cout << \"Acc Number: \"; cin >> accNum;
   for (int i = 0; i<j; i++)
   {
       if (B[i].accNumber == accNum)
       {
           cout << \"Error: No changes should be made to the database\ \";
           return 0;
       }
   }
   j = j + 1;
   B[j].accNumber = accNum;
   cout << \"first name: \"; cin >> B[j].Fname;
   cout << \"last name: \"; cin >> B[j].Lname;
   cout << \"Balance:\"; cin >> B[j].balance;
}
void deleteAccount()
{

   int accNum;
   cout << \"Enter account number: \"; cin >> accNum;
   for (int i = 0; i<j; i++)
   {
       if (B[i].accNumber == accNum){

           for (int k = i; k<j - 1; k++)
               B[k] = B[k + 1];
       }
   }
}
void searchAccount()
{

   int accNum;
   cout << \"Enter account number: \"; cin >> accNum;
   for (int i = 0; i<j; i++)
   {
       if (B[i].accNumber == accNum){

           cout << B[i].accNumber << \"\\t\" << B[i].Fname << \"\\t\" << B[i].Lname << \"\\t\" << B[i].balance << \"\ \";
       }
   }
}
int withdraw()
{
   float withd;
   int accNum;
   cout << \"Enter account number from you want to withdraw:\";
   cin >> accNum;
   for (int i = 0; i<j; i++)
   {
       if (B[i].accNumber == accNum)
       {
           cout << \"Enter withdraw amount : \";
           cin >> withd;
           if (B[i].balance >= withd){
               B[i].balance = B[i].balance - withd;
               cout << \"Total :\" << B[i].balance << \"\ \";
           }
           else{
               cout << \"Error: No changes should be made to the database\ \";
               return 0;
           }
       }
       else{
           cout << \"Error: No changes should be made to the database\ \";
           return 0;
       }
   }
}
int deposit()
{
   float dep;
   int accNum;
   cout << \"Enter account number you want to Deposit:\";
   cin >> accNum;
   for (int i = 0; i<j; i++)
   {
       if (B[i].accNumber == accNum)
       {
           cout << \"Enter deposit amount : \";
           cin >> dep;
           B[i].balance = B[i].balance + dep;
           cout << \"Total :\" << B[i].balance << \"\ \";
       }
       else{
           cout << \"Error: No changes should be made to the database\ \";
           return 0;
       }
   }
}
int transfer()
{

   float tran;
   int fromAcc, toAcc, fr, to, i, f1, f2;
   cout << \"Enter account number you want to transfer from \"; cin >> fromAcc;
   cout << \"to \"; cin >> toAcc;

   for (i = 0; i<j; i++)
       if (B[i].accNumber == fromAcc){
           f1 = 1;
           fr = i;
       }
   for (i = 0; i<j; i++)
       if (B[i].accNumber == toAcc){
           f2 = 1;
           to = i;
       }
   if (f1 == 1 && f2 == 1)
   {
       cout << \"Enter amount to transfer : \";
       cin >> tran;
       if (B[fr].balance >= tran){
           B[to].balance = B[to].balance + tran;
           B[fr].balance = B[fr].balance - tran;
       }
       else{
           cout << \"Error: No changes should be made to the database\ \";
           return 0;
       }
   }
   else{
       cout << \"Error: No changes should be made to the database\ \";
       return 0;
   }
}
void list()
{

   for (int i = 0; i<j; i++)
       cout << B[j].accNumber << \"\\t\" << B[j].Fname << \"\\t\" << B[j].Lname << \"\\t\" << B[j].balance << \"\ \";
}
int main()
{

   int op;
   char ch;
   read_from_file(\"account.txt\");
   do{
       cout << \"-- Operations menu --- \ \";
       cout << \"\\t1. Add an Account\ \\t\"
           \"2. Delete an Account\ \\t\"
           \"3. Search for an account by account number and display the account info\ \\t\"
           \"4. Make a Withdraw\ \\t\"
           \"5. Make a Deposit \ \\t\"
           \"6. Transfer money from one account to another\ \\t\"
           \"7. List all accounts \ \\t\";
       cout << \"Choose the operation : \";
       cin >> op;
       switch (op){
       case 1: addAccount();
           break;
       case 2: deleteAccount();
           break;
       case 3: searchAccount();
           break;
       case 4: withdraw();
           break;
       case 5: deposit();
           break;
       case 6: transfer();
           break;
       case 7: list();
           break;
       default: cout << \"Invalid operation \ \";
           exit(0);
       }
       cout << \"Do you wants more operation (Y/y) by default No : \";
       cin >> ch;
   } while (ch == \'Y\' || ch == \'y\');
}

C201 Team Project 1 1 Goal The purpose of this assignment is to get you familiar with Streams and File IO, Your goal is to create a simple bank database (file) where all the individual accounts are stored in a file. 2 Requirements The following data should be stored comesponding to each account: Account Number: an integer number (must be unique for every account) Name: two words comesponding to the first and last name Balance: a float point number Your program should provide a menu of options that allow performing any of the following operations: Add an account Delete an account Search for an account by account number and display the account info Make a withdrawal Make a deposit Transfer money from one account to another List all accounts Your program should be coded in a way such that all previous changes are written to the file before any new operations are performed. 3 Testing Your program must be able to handle the following abnormal situations: For add an account option, if an existing account is entered, the program should respond with a message and no new account should be created For delete an account option, if the account number could not be found, a message should be displayed and no account should be deleted For withdrawal operation, if the account number does not exist or the balance is not sufficient, a message should be displayed and no changes should be made to the database For deposit operation, if the account number does not exist, a message should be displayed and no changes should be made to the database For transfer operation, if the source account number destination account number does not exist, or the balance of the source account is not sufficient, a be displayed and no changes should be made to the database 4 Notes Please ask the instructor if any part of the assignment is not clear. State your assumptions clearly. Document your code properly. Check and handle all error conditions related to file lo and logical errors related to account operations (e.g. overdraws). You must state clearly your team members at the beginning of the program. 5 Submission upload your source code files (cpp and h) using canvas. One team just needs to make one submission.

Solution

Hi,

Can you please tell what are the errors you are getting in Visual Stdio 2013. Are you saving the program as .cpp extension right ? The same program I tried in Code Blocks its working fine without any errors. Can you please try with other compiler and check whether its working or not.

One more thing, its better to add return 0 in main function.

This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix
This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix
This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix
This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix
This is what i have below for the Project above but i get a ton of errors when I try to build and run it in visual Studios 2013. Can someone please help me fix

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site