Rewrite the following if statement as an equivalent switch statement. The variable digit is of type int.
```
if (digit == 0)
value = 3;
else if (digit == 1)
value = 3;
else if (digit == 2)
value = 6;
else if (digit == 3)
value = 9;
```
```
switch (digit) {
case 0:
case 1:
value = 3;
break;
case 2:
value = 6;
break;
case 3:
value = 9;
}
```
Computer Science & Information Technology
You might also like to view...
Describe the Mac OS X operating system.
What will be an ideal response?
Computer Science & Information Technology
For greatest program efficiency when using the AND operator, first ask the question that is more likely to be true.
Answer the following statement true (T) or false (F)
Computer Science & Information Technology