Write a C++ program that first prompt and read input of two words (1st
word and 2nd
word). It then reads several lines of English text from a file named “HW1in.txt”. The program would replace the first and last occurrence of 1st
word in the each line with the 2nd
word, but leave other occurrence of 1st
word unchanged. It then prints to a file named “HW1out.txt” (a) the original paragraph with the label “Original text:”, followed by the new paragraph with the label “Translated text:”. Note that the 1st
word can be part of another word. For example,
The two words:
me you
Original line:
Give me some men who are stout, hearted men.
New line:
Give you some men who are stout, hearted youn.
CS434 Database Management Systems CS501 – Intensive Computer Science Fundamentals C++ HW 1 This assignment gives you an opportunity to (a) get family with Visual C++ programming environment and (b) practice some simple string processing. You can use either string class or Cstring (i.e., character array) to do this assignment. Problem Statement Write a C++ program that first prompt and read input of two words (1st word and 2nd word). It then reads several lines of English text from a file named “HW1in.txt”. The program would replace the first and last occurrence of 1st word in the each line with the 2nd word, but leave other occurrence of 1st word unchanged. It then prints to a file named “HW1out.txt” (a) the original paragraph with the label “Original text:”, followed by the new paragraph with the label “Translated text:”. Note that the 1st word can be part of another word. For example, The two words: me you Original line: Give me some men who are stout, hearted men. New line: Give you some men who are stout, hearted youn. You may assume 1. There are up to 60 characters in each line of the original text. 2. The new word may be longer than the old one. However, each line will not exceed 80 characters. A possible algorithm (and not the most efficient one): 1. Read the original text line by line and print them to the output file. 2. Prompt the user for the two words and read them into two string variables. 3. Read the original text again line by line starting from the beginning. However, as soon as a line is read, do the translation and print the new line immediately before reading the next one. This way, you don’t have to use a different string variable for each line of input. Sample Input From keyboard me you From file “HW1in.txt” Give me some men who are stout, hearted men. This is the time for all good men to come to the aid of their country. meet me at home Sample Output Original text: Give me some men who are stout, hearted men. This is the time for all good men to come to the aid of their country. meet me at home Translate text: Give you some men who are stout, hearted youn. This is the tiyou for all good men to coyou to the aid of their country. youet me at hoyou Submission This assignment is due Thursday (9/9) at 10:00 PM. Submit a zip file which contains your entire project folder on Moodle (@ http://classes.cs.siue.edu ) by the due time to avoid any penalty for late submission. The final deadline is 10:00 PM Monday (9/13) after which NO program will be accepted.