Well, first of all I'd like to ask how to make the program lookfor the keyboard type (azerty or qwerty) because since I have an azerty one, when I type q it shows up as a and so on...how can I solve this problem?
Also I've written a morse translation program (the idea is from someone else, sorry, but it is just to exercise myself), and I have a problem, each time a letter is translated into morse, I'd like it to rework the whole system so if you type a letter and press enter it continues to give you the answer and then you can again until ESC is pressed, how do I do that? It's the first time I need to apply a loop to several actions, so it's hard. Here's the code:
Hope anyone knows the answer.Code:#include <iostream.h> #include <conio.h> #include <time.h> #include <stdlib.h> #include <windows.h> void main() { char morse; cout<<"Welcome to the Morse Translator (c) v1.0 created by Patrick Marinkovic."; cout<<"To find how a letter of the alphabet is spelt in the Morse language, please type a letter and press Enter. Whenever you wish to exit, press ESC:"; cin>>morse; //now will start the answers code if(morse=='a') { cout<<"._ is a. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='b') { cout<<"_... is b. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='c') { cout<<"_._. is c. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='d') { cout<<"_.. is d. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='e') { cout<<". is e. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='f') { cout<<".._. is f. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='g') { cout<<"_ _. is g. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='h') { cout<<".... is h. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='i') { cout<<".. is i. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='j') { cout<<"._ _ _ is j. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='k') { cout<<"_._ is k. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='l') { cout<<"._.. is l. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='m') { cout<<"_ _ is m. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='n') { cout<<"_. is n. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='o') { cout<<"_ _ _ is o. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='p') { cout<<"._ _. is p. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='q') { cout<<"_ _._ is q. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='r') { cout<<"._. is r. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='s') { cout<<"... is s. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='t') { cout<<"_ is t. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='u') { cout<<".._ is u. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='v') { cout<<"..._ is v. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='w') { cout<<"._ _ is w. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='x') { cout<<"_.._ is x. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='y') { cout<<"_._ _ is y. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else if(morse=='z') { cout<<"_ _.. is z. If you wish to translate another letter please type it and press Enter,otherwise press ESC to exit:"; } else { cout<<"Character not available in Morse language. If you are trying to translate numbers, please await the next version. Please type a letter of the alphabet or press ESC to exit:"; } //here ends the answers code getch(); return 0; }