Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment uses functions, files, and strings. Enough flexibility is provided for you to apply your knowledge of basic C++ programing to develop your solution.

This assignment uses functions, files, and strings. Enough flexibility is provided for you to apply your knowledge of basic C++ programing to develop your solution.

Develop a functional flowchart and then write a C++ program to solve the following problem.

1. Create a text file named file1.txt and write your brand of computer (like Dell, Aplle, etc) in the file. You will be reading the name of the file from the keyboard as a string, using the string class. Your program will also read the brand of your computer from the keyboard. The process of the file creation (name of the file, mode for opening the file, and testing the open success is done in a userdefined function. The function communicates the status of file open to the calling function).

2. Create a text file named file2.txt and write your computer model in the file. You will be reading the name of the file from the keyboard as a string, using the string class. Your program will also read the model of your computer from the keyboard. The process of the file creation (name of the file, mode for opening the file and testing the open success is done in a user-defined function. The function communicates the status of file open to the calling function)

3. Create a text file named myComputer.txt and write the brand of your computer from the file file1.txt, and the model from file file2.txt. You will be reading the name of the file from the keyboard as a string, using the string class. The process of the file creation (name of the file, mode for opening the file and testing the open success is done in a user-defined function. The function communicates the status of file open to the calling function)

4. At this time, each file will have one line of text in it.

5. Prepare the files for reading.

6. Display the results of the three files in the order shown below:

File1.txt your brand of computer as written in the file1

File2.txt your model of the computer as written in the file2

myComputer.txt your computer brand and the model as written in myComputer

Note that there is a single space between the computer brand and the computer model when you display the contents of the file myComputer.txt.

You will use a user-defined function to display all the files at once or one at a time.

7. Close all files. You will use a user-defined function that closes each file separately or all at once.

8. Run the program again and use your choice of the filenames, and different names, different than what you used above and repeat the process.

The programs in the book and sample programs provided show you how to read file names as strings and how to convert the strings to the C string, if needed.

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

Recommended Textbook for

More Books

Students also viewed these Databases questions