一个switch问题

来源:百度知道 编辑:UC知道 时间:2024/06/23 15:38:53
//program7.5
#include <iostream>
#include <conio>

int main(){
int choice;

cout <<"What flavor ice cream do you want?" << endl;
cout << "Enter 1 for chocolate" << endl;
cout << "Enter 2 for vanilla"<< endl;
cout << "Enter 3 for strawberry"<<endl;
cout << "Enter 4 for Yam" <<endl;
cout << "Enter your choice:";
cin >> choice;

switch(choice) {
case 1:
cout <<"Chocolate, Muhammad's favorite ." << endl;
break;
case 2:
cout <<"Valilla,Ismael's favorite " <<endl;
break;
case 3:
cout <<"Strawberry,Adibah's favorite" << endl;
break;
case 4:
cout <<"Yam,Munirah's favorite" << endl;

#include <iostream>
#include <conio>

int main(){
int choice;

cout <<"What flavor ice cream do you want?" << endl;
cout << "Enter 1 for chocolate" << endl;
cout << "Enter 2 for vanilla"<< endl;
cout << "Enter 3 for strawberry"<<endl;
cout << "Enter 4 for Yam" <<endl;
cout << "Enter your choice:";
cin >> choice;
if(choice==1)
cout <<"Chocolate, Muhammad's favorite ." << endl;
else if(choice==2)
cout <<"Valilla,Ismael's favorite " <<endl;
else if(choice==3)
cout <<"Strawberry,Adibah's favorite" << endl;
else if(choice==3)
cout <<"Yam,Munirah's favorite" << endl;