Ask your own question, for FREE!
Mathematics 11 Online
OpenStudy (anonymous):

please can anyone help me with a computer science (c++) problem.......Write a program that reads from the user a letter, and prints out the digit value corresponding to this letter based on the encoding on a mobile phone's keypad. For example, for a, b, or c, the program would print the digit 1. If the letter entered is not one of the letters of the alphabet, print a value of -1. Use a switch statement

OpenStudy (bahrom7893):

easyyy....... but i rly don't feel like doing this hahah

OpenStudy (anonymous):

haha :0

OpenStudy (anonymous):

:)

OpenStudy (anonymous):

i'm still new to the c++ thing so i really need help

OpenStudy (bahrom7893):

just do: cout << "Please enter a letter"; cin >> a; then switch case.. like case a, b, or c display this.. very simple hold on..

OpenStudy (anonymous):

tyt

OpenStudy (bahrom7893):

writing in the compiler.. give me a few mins

OpenStudy (anonymous):

its ok take your time, really appreciate your help

OpenStudy (bahrom7893):

wait what corresponds to what again? like isn't abc on 2, so shouldn't it be 2, not 1?

OpenStudy (anonymous):

oh you're right..

OpenStudy (anonymous):

it's 2 then

OpenStudy (bahrom7893):

#include <iostream> using namespace std; int main() { char letter; cout << "Please enter a letter: "; cin >> letter; switch (letter) { case 'a': cout << "\n2\n" << endl; break; case 'b': cout << "\n2\n" << endl; break; case 'c': cout << "\n2\n" << endl; break; case 'd': cout << "\n3\n" << endl; break; case 'e': cout << "\n3\n" << endl; break; case 'f': cout << "\n3\n" << endl; break; case 'g': cout << "\n4\n" << endl; break; case 'h': cout << "\n4\n" << endl; break; case 'i': cout << "\n4\n" << endl; break; case 'j': cout << "\n5\n" << endl; break; case 'k': cout << "\n5\n" << endl; break; case 'l': cout << "\n5\n" << endl; break; case 'm': cout << "\n6\n" << endl; break; case 'n': cout << "\n6\n" << endl; break; case 'o': cout << "\n6\n" << endl; break; case 'p': cout << "\n7\n" << endl; break; case 'q': cout << "\n7\n" << endl; break; case 'r': cout << "\n7\n" << endl; break; case 's': cout << "\n7\n" << endl; break; case 't': cout << "\n8\n" << endl; break; case 'u': cout << "\n8\n" << endl; break; case 'v': cout << "\n8\n" << endl; break; case 'w': cout << "\n9\n" << endl; break; case 'x': cout << "\n9\n" << endl; break; case 'y': cout << "\n9\n" << endl; break; case 'z': cout << "\n9\n" << endl; break; default: cout << "\n-1\n" << endl; } system("pause"); return 0; }

OpenStudy (anonymous):

it worked, you're the best thank you so much , really appreciate what've done,and sorry it took a lot of time

OpenStudy (bahrom7893):

nah it wasn't that hard hahah np

OpenStudy (anonymous):

thanks :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
2 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
2 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!