Answer to Question #244815 in C++ for Urooj

Question #244815

you have a musical friend ? , If no then sorry you cannot join . If yes , then what instrument you can play , if it is drum or guitar then welcome to the band if none than ,sorry

You cannot join the band .


use string and bool in programming


1
Expert's answer
2021-09-30T06:42:20-0400
#include<iostream>
using namespace std;
bool musical_friend(string n){
	if(n=="no"){
		return false;
	}
	else {
		return true;
	}
}
void join_band(string n){
	if(musical_friend(n)==false){
		cout<<"Sorry you cannot join\n";
	}
	else{
		cout<<"What instrument you can play\n";
		string instrument;
		cin>>instrument;
		if(instrument=="drum" ||instrument=="guitar" ){
			cout<<"Welcome to the band.\n";
		}
		else{
			cout<<"Sorry. You cannot join the band \n.";
		}
	}
}
int main(){
	cout<<"You have a musical friend ?\n ";
	string n;
	cin>>n;
	join_band(n);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Urooj
30.09.21, 14:39

It was so helpful thanks a lot !

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS