Write a program to decipher a numeric code in C++. After years of searching, your team has uncovered a code that could unlock ancient secrets. Based on their research, they have determined the integer 67,796,869 could be the key to the mysteries. The team is certain that the number is a sequence of 2-digit pairs, where each pair represents a letter. They need your help to write a program which displays the decoded message. After your analysis, you realize that you can use the modulus (%) to split off the last 2 digits and store it as a number. Then, you can convert (static_cast) the number to a character. Since there are 8 digits in the number, that means the message will have 4 letters (so you need 4 char variables, c1, c2, c3, c4), and you will have to "split" more than once. Once you have all 4 characters, display them (in order) to the user (The secret message is ...) The program should: contain header comments as shown in class display a "hello" message store the original number as a constant integer store the divisor as a constant integer split the number 2 digits at a time using % and / cast each 2-digit pair to a character variable display the decoded message display a "goodbye" message before exiting the program HINT: Create two additional integer variables, one to hold the quotient (after /) and one to hold the remainder (after %).
Write a
After years of searching, your team has uncovered a code that could unlock ancient secrets. Based on their research, they have determined the integer 67,796,869 could be the key to the mysteries. The team is certain that the number is a sequence of 2-digit pairs, where each pair represents a letter. They need your help to write a program which displays the decoded message.
After your analysis, you realize that you can use the modulus (%) to split off the last 2 digits and store it as a number. Then, you can convert (static_cast) the number to a character. Since there are 8 digits in the number, that means the message will have 4 letters (so you need 4 char variables, c1, c2, c3, c4), and you will have to "split" more than once.
Once you have all 4 characters, display them (in order) to the user (The secret message is ...)
The program should:
- contain header comments as shown in class
- display a "hello" message
- store the original number as a constant integer
- store the divisor as a constant integer
- split the number 2 digits at a time using % and /
- cast each 2-digit pair to a character variable
- display the decoded message
- display a "goodbye" message before exiting the program
HINT: Create two additional integer variables, one to hold the quotient (after /) and one to hold the remainder (after %).
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images