Please help me figure this out. The issue is explained in the description. Thank you.
The problem I'm having is if you enter more than one letter it will output the conversion for the first letter you enter. I want to limit the input to one letter. I want the else statement at the end to be the output if you enter more than one letter. Please help! P.s. If any of you know a simpler way without so much writing to create the same thing I did here please let me know, I would like to get better at this stuff. Thank you. If you want to try the program out or try out possible fixes you can find it in the code playground on the "Most Recent" tab. It is named "Converts letters to decimal, binary & hex" int main() { char letter; cout <<"Please enter a single letter\n"<<endl; cin>>letter; cout<<"You entered "<<letter<<endl<<endl; cout<<"The conversions for "<<letter<<" are:"<<endl; if(letter == 'a' || letter == 'A'){ cout<<"Decimal=1 \n"<<"Binary=00001 \n"<<"Hexadecimal=0x01\n\n"<<"ASCII:\n"<<"For A\n"<<"Decimal=65 \n"<<"Binary=1000001 \n"<<"Hexadecimal=0x41\n\n"<<"For a \n"<<"Decimal=97 \n"<<"Binary=1100001 \n"<<"Hexadecimal=0x61"; } else if(letter == 'b' || letter == 'B'){ cout<<"Decimal=2 \n"<<"Binary=00010 \n"<<"Hexadecimal=0x02\n\n"<<"ASCII:\n"<<"For B\n"<<"Decimal=66 \n"<<"Binary=1000010 \n"<<"Hexadecimal=0x42\n\n"<<"For b \n"<<"Decimal=98 \n"<<"Binary=1100010 \n"<<"Hexadecimal=0x62"; /*The same thing is repeated for letters c through z*/ else cout<<"Error: You did not enter a letter or you entered too many \n"<<"Please enter a single letter"<<endl; return 0; }