1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
disa [49]
3 years ago
12

"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen

ce. 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. C++
Ex: The following patterns yield a userScore of 4:

Ex: The following patterns yield a userScore of 9:

simonPattern: R, R, G, B, R, Y, Y, B, G, Y

userPattern: R, R, G, B, B, R, Y, B, G, Y

Result: Can't get test 2 to occur when userScore is 9
Computers and Technology
1 answer:
m_a_m_a [10]3 years ago
3 0

Answer:

#include <iostream>  // includes input output functions

#include <string> // used for string functions

using namespace std;   // identifies objects like cout , cin

int main() {  // body of the main function

int index;   // index position of the elements

simonPattern = "RRGBRYYBGY";   //stores simon pattern

userPattern = "RRGBBRYBGY";   //stores user pattern

int userScore = 0;  // used to store the user score

// loop compares characters of user and simon patterns

for ( index = 0; userPattern[index] == simonPattern[index]; ++index) {

     userScore = userScore +1; // adds to the user score

     if (userPattern[index] != simonPattern[index]){

//if user and simon pattern do not match

        break;      }   } // breaks the loop

cout << "userScore is  " << userScore; // prints the user score

Explanation:

The program compares the user pattern to simon pattern character by character and keeps adding one to the user score if the characters of both simon and user patterns match. The loop breaks if the character of user pattern does not match with that of simon matter. At the end the calculated user score is displayed in the output.

You might be interested in
Hoda wants to create a new presentation in PowerPoint with existing graphics and designs. What is the easiest and fastest way fo
Paul [167]

Answer: a

Explanation:

6 0
3 years ago
When are computers most vulnerable to threats or damage?
valentinak56 [21]
With virus protection
8 0
4 years ago
Choose the correct option that completes the sentence.
vekshin1

What are the answer options?

5 0
3 years ago
If you need more room on the screen, you can hide the ribbon
kow [346]

Answer:

I hope this helps

Explanation:

The answer is true

8 0
3 years ago
HOLISSS SOY NUEVO AQUI HABLEMOS
UkoKoshka [18]

Answer:

Welcome

Explanation:

This app is not for talking it is for educational purposes so yeah your welcome

BUT NO HATE YOU LOOK COOL MY DUDE

8 0
3 years ago
Other questions:
  • Why does people that gets abused not report?
    5·1 answer
  • What is working with others to find a mutually agreeable outcome?
    6·1 answer
  • Which is the last step in conducting a URL search?
    6·1 answer
  • You're an administrator for a large corporation and you are responsible for deploying computers often and quickly. What server d
    10·1 answer
  • Who found the first computer bug in 1947, and invented the concept of a compiler in 1952
    6·1 answer
  • If myClass has a constructor with a parameter of type String, select the other constructor that should be included.
    14·1 answer
  • Which is the best information to determine an athlete's abilities and needed areas of improvement?
    12·2 answers
  • What is the CPU's role?
    15·2 answers
  • Ethan wants to change the font in his document. He should _____.
    8·1 answer
  • This might sound crazy! But please help.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!