Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started