I'm having trouble transforming the following nested if statement below, into an equivalent switch statement. If anyone can give me some advice, it would be appreciated.
if (num1 == 5)
myChar = ‘A’;
else
if (num1 == 6 )
myChar = ‘B’;
else
if (num1 = 7)
myChar = ‘C’;
else
myChar = ‘D’;
switchstatement you've made, along with any problems you've encountered.java switch statement docsifblocks are not nested. They are chained.char [] chars = {'A','B','C','D'}; int index = num1-5; myChar = chars[index];