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
What does 4g consistâ of?
stellarik [79]
The answer is  (C) broadband cellular networks

Over the past decade, a majority of the mobile service providers have built 3G networks that use packet-switching technologies. Over time, 3G evolved into HSPDA which is five times faster than 3G. Predictably, 4G networks are now commonplace and are built from LTE and Mobile WiMAX.
5 0
4 years ago
How does my car radio know what song is playing?
Alexxandr [17]
It's probably like somebody that's copys it to the car like say the song is a good song (a drake song) it knows I guess or you told your company people to do that for you idrk
5 0
4 years ago
What is the name of the organization responsible for assigning public ip​ addresses?
Veseljchak [2.6K]
Comcast,at&t,and Verizon
8 0
3 years ago
research the risk of social media and list 3 websites that have information about the topic instead of the one you listed on you
Naily [24]
1) Social Life decreased
2) Missing opportunity’s
3)Passing Time
3 0
2 years ago
A statement or account giving the characteristics of someone or something is called?​
vredina [299]

a statement or account giving the characteristics of someone or something is called <u>description.</u>

I hope it's help ^^

7 0
2 years ago
Other questions:
  • "a router interface has been assigned an ip address of 172.16.192.166 with a mask of 255.255.255.252. to which subnet does the i
    5·1 answer
  • The internet is a worldwide assembly of computer
    11·1 answer
  • Why was the internet originally constructed
    5·1 answer
  • How do issues of equity, teacher education and budgeting impact technology in schools?
    7·2 answers
  • A ________ allows users to add, remove, or edit its content. Select one: A. blog B. podcast C. wiki D. chat
    8·1 answer
  • What is the main type of energy used to help convert metamorphic rocks into igneous rocks in the rock cycle ?
    10·1 answer
  • During the _____it is important to figure out how the test will be scored.
    9·1 answer
  • javascript Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment
    7·1 answer
  • How do you enter the decimal 73 into the computer?
    11·1 answer
  • How important are operating system in our devices?​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!