Question
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 c1.txt and write your brand of car (like Dell, HP, 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 car 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).
2. Create a text file named c2.txt and write your car 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 car 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 c1.txt, and the model from file c2.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:
c1.txt your brand of computer as written in the c1
c2.txt your model of the computer as written in the c2
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.
6. NO global declarations of VARIABLES allowed in any program that you develop in this course.
11. Do not use
12. Do not use any #define in your program until the time that is required for class declaration header files.
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