-1

I was wondering if it was possible to use two variables in a switch case.

The assignment was to use the same information that I used to create if else statements and but this time use the switch case. The problem is I have two vars that I used to gather the information residence and hours. I am not sure and cannot figure out if you can use these two in a switch. Thanks for the help.

joePgal
  • 15
  • 1
  • 2
  • Why don't you create an array and add the two varible to it and then loop through them? If you can provide a bit more detail would be great. – zXSwordXz Feb 05 '15 at 04:01

1 Answers1

0

Presumably, it is an expansion of your question: if statements blending together

If you can't use if statements, you can use nested switch statements.

switch (residence) {
  case "house":
    switch (hours) {
      case 12:
        print(...);
        break;
      ...
      default:
        Assert(false);
    }
  ...
  default:
    Assert(false);
}
Community
  • 1
  • 1
Michael Holman
  • 901
  • 1
  • 10
  • 26