Hello.
im a student working in C++ and im fairly new to both C++ and i guess this community.(i was reccomended to come here if i had problems) im just doing some simple exercises or s it seemed. here is the question.
Write a C++ program with a case structure. The program reads in a character from the user, then translates it into a different character according to the following rules:
i. characters X, Y, Z will be translated to characters x, y, z respectively
ii. the space character ' ' will be translated to underscore '_'
iii. digits 0, 1, 2, .., 9 will all be translated to the question mark '?'
iv. all other characters remain unchanged.
The program then displays the translated character.
simple? well i guess, i was able to do most of it but im stuck on Q2 and Q4. i cant find a way to enter spacebar through the case(ive tested other characters to give out the underscore and i have tried some 'getline' stuff) and i am lost upon the last bit. I'm sure it ustilises the 'default' part of the code. bleh maybe i explained incorrectly.
btw im not a slacker asking for easy answers heres what ive done
#include<iostream>
using namespace std;
int main(){
string type2;
char type;
char c;
cout<<"please enter one of the valid characters ";
cin>>type;
switch(type)
{case 'X':
type2="x";
break;
case 'Y':
type2="y";
break;
case 'Z':
type2="z";
break;
case '0': case '1': case '2': case '3': case '4': case'5': case'6': case'7': case'8': case '9':
type2="?";
break;
default :
type2=
;
}
cout<<type2<<endl;
system("pause");
return 0;
}
anyways anyhelp is much appreciated. telling me what im supposed to do or simply pointing me in correct direction would be great.(my textbooks fail at this) and yes i have watched through several 'youtube' style tuts and googled lots but to no sucess.
thnx, Leone, novice c++ student.