Answer to Question #244296 in C++ for Urooj

Question #244296

You want to start a two-piece band, but first you need a friend to join it. If you have a musical friend, you next need to check (using a nested ifstatement) that they actually play an instrument you want in the band. You decide that they need to play either guitar or drums to join.

Write a program that checks to see if you can start a band! You should use the following variables to write your program:

bool musicalFriend = true; string friendPlays = "guitar";


1
Expert's answer
2021-09-30T00:57:34-0400
#include<iostream>
using namespace std;
int main()
{
	bool musicalFriend = true; 
	string friendPlays = "guitar";
	cout<<"Enter the game you can play: ";
	cin>>friendPlays;
	if(musicalFriend==true){
		if(friendPlays=="guitar"){
			cout<<"You can start the band";
		}
		if(friendPlays=="drum"){
			cout<<"You can start the band";
		}	
	}
else{
		cout<<"You cannot start the band";
	}	
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS