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]
4 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]4 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
Which of the following BEST represents the relationship between physical fitness and exercise?
adoni [48]
Exercise is a subset of physical fittness
8 0
3 years ago
Sammy created a new logo for his client enlarged to use on a billboard ad. Now Sammy needs to redo the logo. What should he do t
bazaltina [42]

Answer:

The answer is D. In order to make an advertisement, the photo or photos have to be clear and easy to see. They also have to stay clear when they are enlarged

Explanation:

4 0
3 years ago
A technician is trying to recover information on a computer that has been hidden or deleted on purpose in order to hide evidence
igomit [66]

Answer:

Data recovery

Explanation:

Data recovery -

It is the method involved in computer , where the lost , damaged or corrupted file or data is gained back again , is referred to as data recovery.

The information is recorded by some secondary method , when the file cannot be accessed in the original manner.

Hence , from the given scenario of the question,

The correct term is data recovery.

4 0
3 years ago
Which type of financial institution typically has membership requirements?
Anon25 [30]
Credit Union typically has membership requirements
8 0
4 years ago
What is returned by the code: range (20, 100, 20)
Tju [1.3M]

The code that is returned by the code: range (20, 100, 20)  is known as  (20, 50, 80).

<h3>What is this code about code?</h3>

The line of code is known to be one that often returns the ASCII code as the ASCII is known as American Standard Code for Information Interchange.

Note that the code is made up of   seven bit code and thus the code returned for range (20, 100, 30) is (20, 50, 80).

Learn more about code from

brainly.com/question/20796198

#SPJ1

8 0
2 years ago
Other questions:
  • Melissa is visiting a Web page that her co-workers frequently update throughout the day. If she wants o make sure she has the mo
    11·1 answer
  • Please I need all the help I can get Thank You So Much
    14·1 answer
  • hey computor guys. is the MSI B250M GAMING PRO LGA 1151 Intel B250 HDMI SATA 6Gb/s USB 3.1 Micro ATX Motherboards - Intel compat
    8·1 answer
  • Cloud computing is the fastest growing form of computing. <br> a. True <br> b. False
    9·1 answer
  • What components are in hard drives?
    12·1 answer
  • If an app needs to perform a derived-class-specific operation on a derived class object reference by a base class variable, the
    9·1 answer
  • Business customers pay $0.006 per gallon for the first 8000 gallons. If the usage is more than 8000 gallons, the rate will be $0
    11·1 answer
  • The software maintains and manages information related to employees, rooms, committees, and committee meetings of a company. The
    9·1 answer
  • Which of the following statement is False? 1 point Context free language is the subset of context sensitive language Regular lan
    5·1 answer
  • 1. While researching online, you come across an article that prominently displays the author's name. This source is likely to ha
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!