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

I need help compling this into C++ visual studio. Write a program that calculate

ID: 3882293 • Letter: I

Question

I need help compling this into C++ visual studio.

Write a program that calculates the new balance in bank accounts after interest is added. Data is stored in a file with the following format:

lastName accountNumber currentBalance interestRate

A sample data file is:

Johnson 123-567 2540.00 2.3

Clark 145-234 5435.43 2.5

Miller 345-234 10435.23 3

Your program should read the name of the input data file. Next, calculate the updated account balance. Your output should print the following for each account:

accountNumber lastName updatedBalance

Both the lastName and updatedBalance should be printed 10 characters wide. The lastName should be left justified. The updatedBalance should be right justified and printed to two decimal places.

Sample Run: (the highlighted text is what the user types)

Input filename? acct_data.txt

123-567 Johnson       2598.42

145-234 Clark         5571.32

345-234 Miller       10748.29    

Other Considerations:

Did you remember system(“PAUSE”)?

Did you include comments?

Did you use constants?

Did you remember system(“PAUSE”)?

Did you include comments?

Did you use constants?

Explanation / Answer

//Please see the code below please do thumbs up if you like the solution

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>    
using namespace std;

int main()
{
    ifstream file;
    string lastName, accountNumber;
    double currentBalance, interestRate;

   file.open("input.txt");
    if( !file )
        cout << "Cant open " << endl;


      while(!file.eof())
      {
       file >>lastName>>accountNumber>>currentBalance>>interestRate;
        cout <<accountNumber <<" "<<left <<setw(10) << lastName << setw(10)<< currentBalance+(currentBalance*interestRate)/100 << endl;
      }

    file.close();
    return 0;
}

output:

123-567 Johnson   2598.42
145-234 Clark     5571.32
345-234 Miller    10748.3

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