Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a c++ code for the following problem: Attached is an input file for the exercise. You should use return by value functions, loops, and

Write a c++ code for the following problem:

image text in transcribed

Attached is an input file for the exercise. You should use return by value functions, loops, and external file techniques.

Note: For my input file, for each read I read the entire line. A sample of the code is getline(inData, inputString) ;. See pages 151-152 in the 6th Edition Textbook. I then parse the entire line character by character. This allows me to use this character as input to the Rot13 function.

Assume you have a string with a declared name of inputString. We will take the string and proceed from the start of the string, character by character until we reach the end of the string. As we proceed with examining the string we will pick the current character. Assume the current character is declared as char inChar.

First you need to find the length of the string. Again we will assume a type int of len for string length. The following code should make things a little more clear:

// we can assume you have already read the string inputString.

// again ipos is a type int to keep track of the position you are in the string.

len = inputString.length() ;

for (ipos = 0; ipos

{

inChar = inputString.at(ipos) ;

// now you have the current character and you can do whatever you need to do

}

The above code will go from the beginning of the string until you have examined each character.

ROT13 (rotate by 13 places) is a simple letter substitution cipher that is an instance of a Caesar cipher developed in ancient Rome and used by Julius Caesar who used it in his private correspondence. ROT13 replaces a letter with the letter 13 letters after it in the alphabet. The following table demonstrates the translation in ROT 13 Thus, the translation of the word JULIUS using ROT13 would be WHYVHF. Write a C++ program that asks the user for the name of an input file and translates the contents of that input file using ROT13. Your main function should be responsible for reading the input file and coordinating calls to a value returning function named Rot13 that will do the translation for each character and Write TranslatedChar that will write the translated character to a secondary file. The Rot13 function takes as input the character to be translated and returns the translated character. The second function named Write TranslatedCharwll have two parameters, the translated character and a reference to an ifstream data type for a secondary file named "output.rot13", and write that translated character to this file

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

5. How do instructional objectives help learning to occur?

Answered: 1 week ago