Convert character to operator

Hi all,

I have an assignment for my uni course which requires me to convert a character which has been input into the command line arguments to an operator. So the letter 'a' will be addition, 's' is subtraction, 'm' is multiplication and 'd' is division. I am unsure how to go about this. Is there a specific command that would work, or is it more complex??

Thanks
It depends on what your assignment needs you to do.

Is it simply a matter of replacing 'a' with '+' etc?

In some ways that doesn't get you very far, perhaps instead you need to actually execute some code to carry out the addition? If so, you might use a series of if/else or maybe a switch-case construct.
Topic archived. No new replies allowed.