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
The letters a, e, i, o and u are the only vowels. Write a function named vowelUseDict() takes a string t as a parameter and comp
Andru [333]

Please specify the programming language.


3 0
3 years ago
Computer C’s performance is 4 times as fast as the performance of computer B, which runs a given application in 28 seconds. How
slamgirl [31]

Answer:

112

Explanation:

Since computer C's performance is 4 times faster, naturally I'd multiply 28 by 4.

6 0
3 years ago
Although the first GPS satellite was put into orbit in the ___________, GPS did not provide global coverage until _______.
Ilia_Sergeevich [38]
February 22 1978 and 1992 
5 0
3 years ago
HOWARD!!!!!! THE PHONE IS RINGING!!!!!!!!!
777dan777 [17]

Answer:

i am confused

Explanation:

7 0
3 years ago
Read 2 more answers
How do i win Mine Craft
Vlad [161]
Answer: defeat the dragon? I think
3 0
3 years ago
Read 2 more answers
Other questions:
  • If the physical memory size is doubled without changing any of its other parameters, the number of entries in the page table
    5·1 answer
  • Why do most laptops have LCD rather than OLED displays, which are found on mobile devices?
    14·1 answer
  • This isn't a homework question but rather a technological problem. I connected my device to the motherboard but it will not dete
    5·2 answers
  • Which option describes wearable technology?
    9·1 answer
  • True or False <br><br> Rootkits are only made by black-hat hackers.
    8·1 answer
  • Write a program to generate following series in qbasics 100,81,64,....1​
    13·1 answer
  • CAN SOMEONE PLEASE DO THESE FOR ME I WILL GIVE BRAINLIESR AND 20 POINTS PLEASE ITS ONLY 5 QUESTIONS PLEASEEEE
    12·1 answer
  • You can use a minus sign to make a negative numberlike -2. What happens to each of the following 2++2
    8·1 answer
  • Carl is beginning a digital forensic investigation. he has been sent into the field to collect a machine. when he arrives, he se
    11·1 answer
  • Why we use cluster computing and hadoop framework for big data sysetm​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!