1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
katrin [286]
3 years ago
12

p25: File Write and Read1) User enters a file name (such as "myMovies.txt").2) User enters the titles of 4 of their favorite mov

eis (use a loop!).3) Program Writes the 4 titles to a file, one per line, then closes the file (use a loop!).4) Program Reads the 4 titles from "myMovies.txt" stores them in a list and shows the list5) The program writes the titles in reverse order into a file "reverseOrder.txt"Sample Run:Please enter a file name: myMovies.txtPlease enter a movie title #1: movie1Please enter a movie title #2: movie2Please enter a movie title #3: movie3Please enter a movie title #4: movie4Writing the 4 movie titles to file 'myMovies.txt'Reading the 4 movie titles from file into a list: [movie1, movie2, movie3, movie4]Writing the 4 movie titles in revers to 'reverseOrder.txt'Note: Do not use reverse() , reversed()Content of myMovies.txt:movie1movie2movie3movie4Content of reverseOrder.txtmovie4movie3movie2movie1
Computers and Technology
1 answer:
SCORPION-xisa [38]3 years ago
6 0

Answer:

<em>The program goes as follows  </em>

<em>Comments are used to explain difficult lines</em>

#include<iostream>

#include<fstream>

#include<sstream>

#include<string>

using namespace std;

int main()

{

//Declare String to accept file name

string nm;

//Prompt user for file name

cout<<"Enter File Name: ";

getline(cin,nm);

//Create File

ofstream Myfile(nm.c_str());

//Prompt user for 4 names of movies

string movie;

for(int i = 1;i<5;i++)

{

 cout<<"Please enter a movie title #"<<i<<": ";

 cin>>movie;

 //Write to file, the names of each movies

 Myfile<<movie<<endl;

}

Myfile.close(); // Close file

//Create an Array for four elements

string myArr[4];

//Prepare to read from file to array

ifstream file(nm.c_str());

//Open File

if(file.is_open())

{

 for(int i =0;i<4;i++)

 {

  //Read each line of the file to array (line by line)

  file>>myArr[i];

 }

}

file.close(); // Close file

//Create a reverseOrder.txt file

nm = "reverseOrder.txt";

//Prepare to read into file

ofstream Myfile2(nm.c_str());

for(int j = 3;j>=0;j--)

{

 //Read each line of the file to reverseOrder.txt (line by line)

 Myfile2<<myArr[j]<<endl;

}

Myfile2.close(); //Close File

return 0;

}

See attached for .cpp program file

Download cpp
You might be interested in
Pointsfor a failover cluster, what type of network would you use to communicate with an iscsi device?
guajiro [1.7K]
A local Network..........
8 0
2 years ago
When enter a function or formula in a cell, which is the character you must type?
vladimir1956 [14]
The answer is A. For instance, to use the sum function, you would need to =SUM()
7 0
3 years ago
What is the easiest way to be sure you have selected all of the content related to a specific tag?
pychu [463]
Add a <div> around it.
example:
<div id = "content">
<p> content</p>
</div>
4 0
3 years ago
When talking about changes related to information​ technology, the text identifies three interrelated changes that are responsib
Travka [436]

Answer:

The Growing use of Big data

Explanation:

In information technology big data is along with mobile digital platforms and cloud computing are responsible for bulk of innovations.

Big data is a large set of data that can be analyzed and used for pattern recognition, and extract information from different collection of data. This analysis or collection of data leads to innovation in the field of information technology.

8 0
2 years ago
Your company has purchased another company that also uses Windows Server 2016 and Active Directory. Both companies need to be ab
Scorpion4ik [409]

Answer:

Create a two-way forest trust

Explanation:

The aim here is to ensure that both companies are able to access the forest resources of each other. The creation of a Two-way Forest Trust would guarantee that as if the Two-way Forest Trust is created between Forest A and Forest B, being the forest resources of the two companies respectively, then all the domains in Forest A will trust every domain in Forest B and vice versa.

5 0
2 years ago
Other questions:
  • Given the following code, what is output by the method call, mystery(6 * 8)?
    8·1 answer
  • The document responsible for describing the type of data stored in the database is called the:
    5·1 answer
  • What should you do before cleaning the top of a storage battery and rinsing it with fresh water?
    12·1 answer
  • Utility software is also known as _____​
    11·1 answer
  • William wants to create a document using a DTP<br> what time saving techniques can he use?
    9·1 answer
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • Information about www
    14·1 answer
  • How many levels of heading tags are allowed in html?
    13·2 answers
  • What are the parts of a file?​
    9·1 answer
  • When right-clicking an object, a ____ menu appears, which contains frequently used commands related to the object.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!