Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem B: File by command (20 points) Write a C++ program that repeatedly accepts single word commands and then sentences until the user tells the

image text in transcribed

Problem B: File by command (20 points) Write a C++ program that repeatedly accepts single word commands and then sentences until the user tells the program to stop. You should create a text file called "out.txt" from these commands. There are four commands you need to handle: new - will create a new blank file with just the following sentence in it. append- will add the sentence to the end of the file prepend - will add the sentence to the start of the file exit will cease asking questions and stop the program. In this case, there will not be a sentence following the command. . Your program should be able to handle any combination of these commands. You can create temporary text files if you think this would be useful, but the final "out.txt" needs to follow the commands as described. You can assume the "new" command will always be run first. Make the "out.txt" in the current directory with the cpp file (i.e. do not assume any directory structure). Example 1 (user input is underlined): Command? new Hello Command? append there Command? asdf Command? exi Resulting "out.txt" for example1 asdf Hello there

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago