Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE ANSWER IN C++ NOT JAVA \"Simon Says\" is a memory game where \"Simon\" ou

ID: 3804620 • Letter: P

Question

PLEASE ANSWER IN C++ NOT JAVA

"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement.

PLEASE ANSWER IN C++ NOT JAVA

Ex: The following patterns yield a userScore of 4: ALSO NEED SO IT CAN DO OTHER userScore of 9:

4

Testing: RRRRRRRRRR/RRRRRRRRRY

9

4

Tests aborted.

Your value:

4

Explanation / Answer

code:

#include<iostream>
#include<cmath>
#include<string>
using namespace std;


int main()
{
cout<<"enter simon string";
string str1;
cin>>str1;
cout<<"enter user string";
string str2;
cin>>str2;
int i=0;
int userscore =0;
while(i<str1.size() && str1[i]==str2[i])
{
userscore++;
i++;
}
cout<<"userscore is :"<<userscore;
return 0;

}

sample output:

mitali@Infoweave:~/Desktop/chegg$ ./a.out
enter simon stringRGB
enter user stringRGR
userscore is :2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote