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
Copyright laws protect:This task contains the radio buttons and checkboxes for options. The shortcut keys to perform this task a
agasfer [191]

B- Copyright laws protect original works both online and in print.

3 0
3 years ago
Josh is searching for information online about the conservation status of blue jays. He enters the phrase blue jays and most of
Alona [7]

Answer: specify the bluejay bird

Explanation:

by specifically mentioning it is birds he wants that Is the results he will get

5 0
3 years ago
As a high school student, what do you think is the advantage of someone who has knowledge about the basics of internet compared
serg [7]

Answer:

For your future in your career, you will definitely have an upper hand and will be able to access and use more tools.  But the person that has never used a computer before does not know what exactly they are missing.  When they try to use a computer, they will struggle with simple task that now come naturally to you.

Explanation:

8 0
2 years ago
Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime
Sidana [21]

Answer:

Following are the code in the Java Programming Language.

//print first element of the array

System.out.println(runTimes[0]);

//Print second element of the array

System.out.println(runTimes[1]);

//print third element of the array

System.out.println(runTimes[2]);

Explanation:

<u>Following are the description of the Program</u>:

In the above program, There is the integer type array variable that is 'runTimes' and its index value is 5. Then, initialize values in the array one by one which means firstly, they insert in index 0, then in index 1, and so on. Finally, we have to print the first three elements of the array. So, we set the System.out.println() function three times to print array by passing array name and first three index value with it.

3 0
3 years ago
Implement Shift cipher using Python or Java. The user should be prompted to provide a number between 0-25 and pick encryption (e
sveticcg [70]

Answer:

See below

Explanation:

This question is usually in response to having just learned arrays and string/character processing.  Also, encrypted text is all caps, decrypted text is all lowercase.  Convert the string accordingly with the uppercase/lowercase functions for your particular language.

Then, follow the following algorithm:

Loop through each character of the string.  Add (or subtract if decrypting) the character.  If it goes beyond the last letter of the alphabet, then subtract the shift from 26 (which is the number of letters in the alphabet.  Add the character to a new string, and return it.

5 0
3 years ago
Other questions:
  • To construct a histogram using excel's chart tools, choose __________ as the chart type.
    5·1 answer
  • For your biology class, you have taken a number of measurements for A plant growth experiment. you wish to create a chart that s
    6·1 answer
  • Which of the following things would you access from the Program &amp; Courses page? Course descriptions Tutorial videos Account
    7·1 answer
  • Complex machines are defined by...
    14·2 answers
  • We use them every day, but what is the overall purpose of a search engine?​
    10·2 answers
  • Do you think an employer can accurately judge an applicant’s skills and character by reviewing his/her job application? Why or w
    14·1 answer
  • ALGUEM SABE COMO MUDA O NOME DE PERFIL!?!?!? SE SOUBER ME AJUDA!!
    14·1 answer
  • Por favor alguem poderia me falar qual PC e melhor: Computador Gamer Fox PC FPS Intel Core i5 8GB (GeForce GTX 1050Ti 4GB GDDR5)
    15·1 answer
  • 1.A tachometer measures:
    15·1 answer
  • If a printer can print 10 characters per second how many minutes (rounded) would it take to print a page with 66 lines of 80 cha
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!