Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago