the statements are the same in actionscript..java..c..c#...etc...its easy..
switch (command){ //command is the actual command (add..)
case 'add': ; break;
case 'sub':; break;
case 'mul':; break;
case 'div':; break;
default: ; break;
}
the variable command is a string that actually contains the command...(either add...sub...mul....div)...
the default keyword at the end is for handling unknowns....
although the syntax may change a little...this snippet will work in most oop languages built from c...
2007-11-30 04:11:35
·
answer #1
·
answered by massiv_x 3
·
0⤊
0⤋
here is a javascript function:
function compute(x, y, operation) {
switch(operation) {
case "add": return x + y; break
case "subtract" : return x - y; break;
case "multiply" : return x * y; break;
case "divide": return x / y; break;
default: return "invalid operator";
}
}
or search google
2007-11-30 04:07:56
·
answer #2
·
answered by Rolly R 2
·
1⤊
0⤋
Programmers usually expect to be paid for their services, especially when I (or we) do all the work.
2016-04-06 05:30:18
·
answer #3
·
answered by ? 4
·
0⤊
0⤋
What language are you using? Have you read the book or paid attention at all?
2007-11-30 03:55:45
·
answer #4
·
answered by Yoi_55 7
·
0⤊
1⤋
Show me what you have so I may help you....
2007-11-30 03:53:07
·
answer #5
·
answered by ? 6
·
2⤊
0⤋