1st C++ Project

Hi all. I am brand new to C++ (3 weeks). I just got my first project to do. Basically the instructor wants us to write a program that reads in numbers similar to a cell phone during a text message (ex 222= a, 444=i, etc). So 2-9 are used for letters, 1 is used to tell the program to convert the string of numbers to a letter, 0 is a space, and 00 is the ending. I must confess I am pretty much lost. I went to a tutoring session tonight and left more or less no better off. If anyone could give me an idea of where to start I'd be greatful. I have the algorithm mapped out but I am struggling to convert it to code. I need a nudge in the right direction.


Thanks,
Marcus
Perhaps you should post your algorithm. Also post an example input with the desired result, since I don't really understand why you need to input '1'.
"222"=="a"? Shouldn't "2"=="a", "22"=="b", and "222"=="c"?
For this project, design and implement a Visual C++ .NET program that will simulate a simple text messaging system. The only characters that you can send are A to Z and space. A space is represented by sending a single 0. Each character that is entered is separated from the next character by a 1. Two consecutive 0 digits will end the text message. We will not need to enter a 1 after a space (0), since text messages will not have 2 consecutive spaces, except at the end of the message. For example, to send the two-character text message "CS" you would see the input stream "2 2 2 1 7 7 7 7 1 0 0". Your project should read in a sequence of integers that represent the encoding of multi-character text message, and then print out that text message. For this project, you can assume that the input will be legal. A complete message will contain several 1’s plus the appropriate number of the digits 2 through 9 and 0 to create and terminate a message.


Thats the project. Some sample i/o

The input:
4 44 1 0 5 5 5 1 4 4 4 1 5 5 1 3 3 1 0 4 4 4 1 2 2 2 1 3 3 1 0 2 2 2 1 7 7 7 1 3 3 1 2 1 6 1 0 0

would yield:
i like ice cream


Pseudo-code:
Start:
Declare & initialize variables needed
Read the 1st number
Loop until “finished”: (How do you know when you‟re finished?)
Is number a 0?
Yes: Save the number in “last number” and set the counter to zero;
Is number a 1?
Yes: (You should have read the numbers for a specific letter. Print it out.)
Print out the correct number for the “last number” entered, and the value
of the counter.
For example, if the last number is a 2 and the counter is 1, print "A.‟
Or if the last number is an 8 and the counter is a 2, print "U.‟
After you‟ve printed the letter, set the counter to 0 and the last number to 1.
Is the number a 2, 3, 4, 5, …, 9?
Yes: Save it in “last number,” increment the counter.
Otherwise (number is not in 0 – 9) print an error message, including the number.
Read another number, and then go back to the top of the loop.
End of loop (when you‟re “finished)
Quit.
Last edited on
Topic archived. No new replies allowed.