Convert the following nested ifelse statements to a switch s
Convert the following nested if/else statements to a switch statement: (8 points)
if (rank == 1 || rank == 2){
cout<<”Lower Division”<<endl;
}
else {
if (rank == 3 || rank == 4){
cout<<”Upper Division”<<endl;
}
else {
if (rank == 5){
cout<<”Graduate Student”<<endl;
}
else {
cout<<”Invalid Rank”<<endl;
}
}
}
Solution
switch(rank)
 {
 case 1:
 case 2:
 cout << \"Lower Division\" << endl;
 break;
   
 case 3:
 case 4:
 cout << \"Upper Division\" << endl;
 break;
   
 case 5:
 cout << \"Graduate Student\" << endl;
 break;
   
 default:
 cout << \"Invalid Rank\" << endl;
 break;
 }

