Convert letter in telefone numbers

I need help in my homework and can't find the beginning of my exercise. The exercise is:
Some companies use letters to show their telephone numbers. For example the number 438-5626 can be show as GET LOAN. Write a program that prompts the user to enter a telefone number expressed in letters and output the corresponding telephone number in digits. If the user enter more than 7 letters, then process only the first seven letters. Also output the - (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover your program should process as meny telephone numbers as the user wants.

This exercise I understand that is a repeticion structure with nested I will apreciate your help!!!!!

Thanks
You need a counter to track number of letters processed. Once counter == 3 then output - and stop when counter == 8. You could use while counter < 8 loop with a if counter == 3 inside for the -.

User may type <7 letters so be careful for that.

Iterate each character in input. Alas C++ has no foreach but you can still loop in string until \0. Now you can use a switch. For cases 'A' 'a' 'B' 'b' 'C' 'c' you output 2 etc., for case else output same character until you endl at the end with counter == 7.

Hotaru
Topic archived. No new replies allowed.