Write a C++ program on If you have a musical friend, you next need to check (using a nested if statement) that they actually play an instrument you want in the band. You decide that they need to play either guitar or drums to join.
#include <iostream>
using namespace std;
int main(){
char answer=' ';
cout<<"Do you have a musical friend? y/n: ";
cin>>answer;
if(answer=='y' || answer=='Y'){
int ch;
cout<<"Does he play either 1. guitar, 2. drums, 3. other?: ";
cin>>ch;
if(ch==1 || ch==2){
cout<<"The friend can join.\n";
}else{
cout<<"The friend can't join.\n";
}
}else{
cout<<"The friend can't join.\n";
}
cin>>answer;
return 0;
}
Comments
Leave a comment