Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In basic C++ please. (1) Write a program to read a text file containing a secret message. Start by reading the input and output file

In basic C++ please.

(1) Write a program to read a text file containing a secret message. Start by reading the input and output file names entered by the user through standard input. The input file contains a text with hidden words, represented by uppercase letters. The input file will contain multiple lines, each representing a new word of the hidden message.

Ex: if the user inputs:

input.txt output.txt 

and if the following message is in the input file:

Hi it has bEen a whiLe since i Last saw yOu 

The secret message is:

HELLO 

Output the secret message into the output file specified by the user. If the message contains multiple words, separate them with whitespaces and end with a new line.

It is possible that the specified input file does not exist, in which case you should print the message

File not found 

and end the program

(2) Read an additional line from standard input and encrypt in it the secret message, using the same strategy of capitalizing the letters. You can assume that the input will consist of only one line and all letters in this line will be initially lowercase. For example, the line could be:

i have always wanted to learn to play soccer. 

After encrypting HELLO (the hidden message found at the previous step) the line would look like this:

i HavE aLways wanted to Learn tO play soccer. 

Note that the letter have been capitalized in the order in which appear, to maintain the readability of the hidden message. Add the new line with the encrypted message to the same output file, after adding a new line to separate it from the hidden message. For example, the whole output file from the example above would look like this:

HELLO i HavE aLways wanted to Learn tO play soccer. 

Hints:

  • The functions toupper(char), tolower(char) and isupper(char) will be useful in this exercise. They all can be used on characters within a string. No additional libraries required.
  • If you can not complete (2), you can safely ignore that portion of the input.

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago