Ok I need to create a program that gets input from a person... I can type a number 0-9 and need to get it to spell it out and vice versa...I need to be able to have the program distinguish if the person types 1 followed by enter -it needs to return out one... if the user types one- followed by enter - then the program needs to return 1.
I can make either work on separate programs.... but need it to be in one program. So how would I do that?
if the person types 1 followed by enter -it needs to return out one... if the user types two- followed by enter - then the program needs to return 2.
"?
If that is the case then you need to create a variable like: int x; and initialize the variable: std::cin>>x; and then return it: return x;. If this is not what you are trying to say then please kindly fix your post. Thank you!
Ok.... let me clarify :)
I want to create a program that when the user enters the number 1 - it will output one. If the user inputs one - it will output 1.
so I wanted a program that would distinguish if the user inputs a number from 0 -9 that it will read from a vector - which I can do.
I also want it to distinguish if the user inputs a number spelled out one - nine... if will output that number in numeric form such as 1 (this can be either another vector or an if else if statement).
I need to know how I can do this so I can just ask the person
"Input a number 0 -9 or zero - nine and I will output its digit or spelled out number" Example user hits 1 then hit enter the output is one. if the user inputs eight then hits enters the output is 8
I can make either work on separate programs.... but need it to be in one program. So how would I do that?
The only thing that may make this awkward is if you were using formatted input extraction (cin >> variable) in your separate programs. All you need to do to make them work together is use getline to get your input, determine if the text extracted is numeric or alphabetic and feed the input to the correct function.