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";
#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";
}
}
Comments
Leave a comment