Week 8 Selection Control Structures
Week 8 Selection Control Structures
1. if(angle == 90){
cout<<"The angle is a right angle!!";
}else{
cout<<"The angle is not a right angle!!";
}
1. if(ace<25){
sum = sum+a;
}else{
count=count+1;
}
2. if(c==15){
credit=10;
limit=1200;
}else{
credit=8;
limit=800;
}
3.) Rewrite the following if-else chain by using a
switch statement:
switch (gradeletter){
case "A":
cout<<"The numerical grade is between 90 and 100 \n";
break;
case "B":
cout<<"The numerical grade is between 80 and 89.9 \n";
break;
case "C":
cout<<"The numerical grade is between 70 and 79.9 \n";
break;
case "D":
cout<<"How are you going to explain this one? \n";
break;
default:
cout<<"Of course I had nothing to do with my grade. \n";
cout<<"It must have been the professor's fault' \n";
}