int main () { } //----- DecryptCipherString() ----------------------------------
ID: 3532624 • Letter: I
Question
int main ()
{
}
//----- DecryptCipherString() ----------------------------------------------------------------------------------
// Decrypts a ciphertext string and returns the decrypted plaintext character. This function is basically a big
// if-elseif-elseif-... statement.
//--------------------------------------------------------------------------------------------------------------
???
???
// Define a char variable named 'plainchar' and initialize it to the space character ' '.
???
// If pCipherString is equal to the string " ** *" Then
// plainchar <- 'A'
???
// Else if pCipherString is equal to the string " * *" Then
// plainchar <- 'B'
???
// Else if pCipherString is equal to the string " ***" Then
// plainchar <- 'C'
???
// ... and so on for each of the remaining characters.
???
// Return plainchar
???
// End the function
???
//----- ReadCipherString () ------------------------------------------------------------------------------------
// When this function is called, the input stream pointer is pointing at the beginning of a ciphertext string
// which consists of five star and space characters, e.g.,
//
// + -- These are characters in the file which have already been read and processed.
// |
// | +---+--- A ciphertext "character" is actually a 5-char string containing '*' and ' ' chars.
// | | |
// V V V
// .....* * *.....
// ^ ^
// | |
// | +-- These are characters in the file which we have not read yet
// |
// +-- This is the position of the input stream pointer
//
// What we need to do is read the five characters starting at the position of the input stream pointer and turn
// these five characters into a string object which we will return. This can be accomplished by writing a count-
// ing loop which executes five times. Each time through the loop we read a single character using the input
// stream get() function -- we use get() because it reads and returns spaces. For each character that we read,
// we stick it onto the end of a string object using the string concatenation operator. After doing this five
// times, we have a five character string containing the stars and spaces.
//--------------------------------------------------------------------------------------------------------------
???
???
// Define and instantiate a string object named 'cipherstring' and initialize this string object to the empty
// string with the assignment operator.
???
// Write the first line of a counting loop (using a for loop) which executes five times, i.e., initialize an
// int variable named 'cnt' to 1, and each time through the loop, increment 'cnt'. Keep looping as long as
// 'cnt' is less than or equal to 5.
???
// Call pFin.get() to read a single character. Store the character into a char variable named ch.
// You need to define ch.
???
// Concatenate ch onto the end of cipherstring using the string concatenation operator +.
???
// End the for loop.
???
// Return cipherstring.
???
// End the function
Explanation / Answer
Wait I am working on it....If I get late please rate me with 5 stars ...i will post the answer in comments........thanx
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.