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]
2 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]2 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
Point mode allows you to select cells for use in a formula by using your finger or the pointer
Serga [27]
That statement is true

in excel, you could enter point mode by pressing any keyboard navigation such as page down, page up, or the arrow keys or by clicking any cells in the worksheet

This mode will select a cell or range as formula operand


7 0
3 years ago
What is the best description of a programming language?
sergejj [24]

Answer: A: A language that directs a computer to perform tasks and carry out

functions

Explanation: I'm a programmer, and coder, this is the best answer from the given choices

4 0
2 years ago
a. Describe how the student can use the jar of rice to model particle motion of a substance in each state of matter: solid, liqu
Black_prince [1.1K]

Answer:

because the jar is ........

4 0
2 years ago
What are the benefits of PowerPoint
Leto [7]
I guess you could say it offers a easier and faster way to facilitate the spread of information through visual displaying of the said information.
5 0
3 years ago
Read 2 more answers
What is the ascii code for the letter D
PilotLPTM [1.2K]

Answer:

068

Explanation:

Or if you want binary it's 01000100

4 0
2 years ago
Other questions:
  • manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
    10·1 answer
  • A .jpg file is an example of which of the following file types
    15·2 answers
  • Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
    6·1 answer
  • What is the purpose of the Excel Function Reference?
    9·1 answer
  • Why is dark supereffective against ghost?
    5·2 answers
  • Why do relational databases use primary keys and foreign keys?.
    12·1 answer
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
  • Can somebody please help me with these few questions?
    11·1 answer
  • What was the name of the first computer, developed by charles babbage?.
    7·2 answers
  • The _____ feature enables you to represent text as colorful visuals.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!