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
son4ous [18]
3 years ago
5

"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. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY
Computers and Technology
2 answers:
weqwewe [10]3 years ago
5 0

int main() {

string simon_Pattern;

string user_Pattern;

int userScore;

int i;

user_Score = 0;

simon_Pattern = "RRGBRYYBGY";

user_Pattern = "RRGBBRYBGY";

for (i = 0; i <= simson_pattern.length; i++) {

if (simon_Pattern[i] == user_Pattern[i]) {

user_Score = user_Score + 1;

} else {

break;

}

}

cout << "userScore: " << user_Score << endl;

return 0;

}

Here it uses two string variable to store “simson’s pattern and user’s pattern”. Then a “for loop” is executed till the end of the string. Inside the for loop both the strings are compared character by character and when found the score is added. If not for loop is exited and finally the score is displayed.

Fofino [41]3 years ago
5 0

Answer:

The code is given below in Java

Explanation:

import java.util.Scanner;

public class SimonSays

{

  public static void main(String[] args)

  {

      String simonPattern = "";

      String userPattern = "";

      int userScore = 0;

      int i = 0;

      userScore = 0;

      simonPattern = "RRGBRYYBGY";

      userPattern = "RRGBBRYBGY";

      for (i = 0; i < simonPattern.length(); i++)

      {

          if (simonPattern.charAt(i) == userPattern.charAt(i))

          {

              userScore = userScore + 1;

          }

          else

          {

              break;

          }

      }

      System.out.println("userScore: " + userScore);

      return;

  }

}

You might be interested in
In the event that a software product fails within a predetermined. Clients use a​
Musya8 [376]

Answer:

try to update product software it will working

Explanation:add license product of a software

5 0
4 years ago
Why does Microsoft release new versions of its Windows operating system every few years?
Korolek [52]
A to keep up with advances in computer capabilities
8 0
4 years ago
What department is cyber security
Paul [167]

Answer:

United States Department of Homeland Security

The National Cyber Security Division (NCSD) is a division of the Office of Cyber Security & Communications, within the United States Department of Homeland Security's Cybersecurity and Infrastructure Security Agency.

<em>Give</em><em> </em><em>me</em><em> </em><em>brainliest</em><em> </em>

8 0
3 years ago
Read 2 more answers
Hi AllyUbongAbasiEtuk
Ainat [17]

Answer:

not a valid question

Explanation:

4 0
4 years ago
Read 2 more answers
Type the correct answer in the book spell all words correctly Michael and Bob are discussing the execution of a JavaScript code
g100num [7]

Answer: I think C++ of https

Explanation: I hope it's right

6 0
4 years ago
Other questions:
  • What view and zoom setting do you need for true WYSIWYG display? Why?
    14·1 answer
  • What is wrong, logically, with the following code? if (x &gt; 10) System.out.println("Large"); else if (x &gt; 6 &amp;&amp; x &l
    11·1 answer
  • You type. The word "weather" when you ment "whether" when will the writer or word flag this as a misspelling or a grammar proble
    13·1 answer
  • which of these should be reportable diseases to protect public health? A. Obesity B. Diabetes C.Measles D. Lung Cancer
    10·2 answers
  • Given the class definition: class CreateDestroy { public: CreateDestroy() { cout &lt;&lt; "constructor called, "; } ~CreateDestr
    6·1 answer
  • Xavier buys a new laptop for $540. He makes a down payment $75 and pays the rest in 6 equal monthly payments, p. What equation r
    7·1 answer
  • Section A: A(n) is a collection of information, generally stored as computer files. The information it contains can be stored, u
    10·1 answer
  • NEED HELP
    9·1 answer
  • You can create an arraylist using _________. a. new arraylist[] b. new arraylist[100] c. new arraylist&lt;&gt;() d. arraylist()
    9·1 answer
  • What virtual, logically defined device operates at the data link layer to pass frames between nodes?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!