Question: Copy the block of code into your C++, make changes as directed in the comments, and cope and paste the edited code This assignment came

Copy the block of code into your C++, make changes as directed in the comments, and cope and paste the edited code

This assignment came with a txt file quoting "Marty McFly 1955"

Code:

// PreLab 2 Assignment

// Write a program that copies the data in the

// prelab input file to an output file "flux_capacitor"

// so that it is formatted the same in both files.

// Additionally add 30 to the year when you rewrite

// it to the output file to help Marty Mcfly get back to

// his proper time.

#include

#include

using namespace std;

int main() {

// ADD HERE declare variables

// declare input file stream variable and open file

ifstream fin;

fin.open("prelab_input.txt");

// Test to see if file correctly opened. If statements will

// be learned in the future. For now, don't worry about

// understanding this.

if (!fin) {

cout << "ERROR - File failed to open. make sure that " << "the input file and this file are in the"

<< "same directory" << endl;

return -1;

// Return statement will terminate the program. We do not want

// to continue if we do not have a valid input file.

}

// declare output file stream varaible and open file

ofstream fout;

fout.open("flux_capacitor.txt");

// ADD HERE write your code here

// closing files

fin.close();

fout.close();

return 0;

}

Please make sure :

-Variable names must be descriptive -Each line in the code must be no longer than 80 characters in length -Nested blocks of code must be indented consistently -Data from the input file stored in input variables -Year value incremented by 30 -Data stored in variables written to the output file -Data format in the output file matches the data format in the input file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!