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
How many keywords are there in C programming language
kumpel [21]
In total there are 32 keywords in the c programming language.
3 0
3 years ago
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
Nana76 [90]

<u>Answer:</u>

<em>using System; </em>

<em>public class Program </em>

<em>{ </em>

<em> public static void Main() </em>

<em> { </em>

<em> String input ; </em>

<em> while(true) </em>

<em> { </em>

<em>  input = Console.ReadLine(); </em>

<em>  if(input.Equals(""quit"")) </em>

<em>  break; </em>

<em>  Reverse_String(input); </em>

<em> } </em>

<em> return; </em>

<em> } </em>

<em>static void Reverse_String(string input_text) </em>

<em>{ </em>

<em>    char[] text = input_text.ToCharArray(); </em>

<em>    Array.Reverse(text); </em>

<em>    Console.WriteLine(text); </em>

<em>} </em>

<u>Explanation:</u>

<em>In the above program a separate function is written to reverse the string.</em>

This method takes the string as an argument and place it in a array and then use the built-in function reverse and print the reversed string in the console.

<em>In the main(), the input is obtained from the console and it is passed to the reversestring(). </em>

7 0
3 years ago
Read 2 more answers
Write the interface (.h file) of a class Counter containing: A data member counter of type int. A data member named counterID of
OlgaM077 [116]

Explanation:

See the attached image for The interface (.h file) of a class Counter

8 0
3 years ago
Alan is the security manager for a mid-sized business. The company has suffered several serious data losses when mobile devices
Kipish [7]

Disk encryption is highly risky response.

<u>Explanation:</u>

To protect or loss of serial data loss on mobile devices it is not advisable to implement full disk encrypted. Once full disk encrypted is implemented mobile access is very slow. End-user will complain to IT administrator.

Best solution either removes unwanted or unauthorized application from mobile to protect the data loss. Install antivirus program in each mobile.

Access or permission to application is removed so that mobile data loss can be avoided.  End user should also be advised not to click on any link which they receive through SMS messages or other through any applications.

5 0
3 years ago
Algebraic concepts that include certain words and phrases and
Veseljchak [2.6K]

Answer:

Boolean Operators

Explanation:

When performing a boolean search, boolean operators allow users to combine keywords with operators (or modifiers) such as AND, NOT and OR to further produce more relevant results.

The boolean operators AND and OR are used to include certain words and phrases during the search while the  boolean operator NOT is used to exclude certain words and phrases.

6 0
3 years ago
Other questions:
  • 1).
    12·1 answer
  • Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integer
    14·2 answers
  • Consider the following sequence of items 10, 36, 25, 54, 37, 12, 75, 68, 42, 86, 72, 90. Insert these items in the order above,
    5·1 answer
  • PLEASE HELPPPPPPP
    15·1 answer
  • When a hardware or software interrupt occurs, the CPU calls________
    14·1 answer
  • Assume you have a int variable n that has already been declared and initialized. Its value is the number of integers that need t
    13·1 answer
  • Please help! Answer this question if you know computer science very well. I need help with computer science.
    13·1 answer
  • Consider the following code.
    7·2 answers
  • Answer all of the questions,
    7·1 answer
  • What is the minimum ethernet frame size that will not be discarded by the receiver as a runt frame?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!