Given a int variable named yesCount and another int variable named noCount and a char variable named response, write the necessary code to read a value into response and then carry out the following: if the character typed in is a y or a Y then increment yesCount and print out "YES WAS RECORDED" if the character typed in is an n or an N then increment noCount and print out "NO WAS RECORDED" If the input is invalid just print the message "INVALID" and do nothing else.
.
.
Click on the title for the solution
.
.
cin>>response;
switch(response)
{case 'y':{ yesCount++; cout<<"YES WAS RECORDED";break;}
case 'Y':{ yesCount++; cout<<"YES WAS RECORDED";break;}
case 'n': {noCount++; cout<<"NO WAS RECORDED";break;}
case 'N': {noCount++; cout<<"NO WAS RECORDED";break;}
default : cout<<"INVALID";}
.
Click on the title for the solution
.
.
This is the answer:
:
cin>>response;
switch(response)
{case 'y':{ yesCount++; cout<<"YES WAS RECORDED";break;}
case 'Y':{ yesCount++; cout<<"YES WAS RECORDED";break;}
case 'n': {noCount++; cout<<"NO WAS RECORDED";break;}
case 'N': {noCount++; cout<<"NO WAS RECORDED";break;}
default : cout<<"INVALID";}
Comments
Post a Comment