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]
2 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]2 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]2 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
True or false? If you’re posting the same content across different channels, make sure you post them simultaneously—on the same
alukav5142 [94]

Answer:

The answer is true.

Explanation:

7 0
2 years ago
Yuri is a skilled computer security expert who attempts to break into the systems belonging to his clients. He has permission fr
Tatiana [17]

Answer:

b) White-hat hacker

Explanation:

This is also called an ethical hacker. Unlike the other options, a white-hat hacker is a person specialized on computational security which offers services to organizations to test how safe they are from informatic attacks (viruses, theft of information, etc). This is carried out  based on a agreement between the whihte-hat hacker and the client via a contract.  

8 0
3 years ago
Write a program that initializes an array with ten random integers and then prints four lines of output, containing (Horstmann,
Amiraneli [1.4K]

Answer:

import java.util.Scanner;

import java.util.Random;

public class Solution

{

public static void indexEven(int[] randomNumbers)

{

System.out.print("Even index elements are: ");

for (int i = 0; i < randomNumbers.length; i++)

{

if (i % 2 == 0)

{

System.out.print(randomNumbers[i] + " ");

}

}

System.out.println();

}

public static void evenelement(int[] randomNumbers)

{

System.out.print("Every even element: ");

for (int i = 0; i < randomNumbers.length; i++)

{

if (randomNumbers[i] % 2 == 0)

{

System.out.print(randomNumbers[i] + " ");

}

}

System.out.println();

}

public static void reverseOrder(int[] randomNumbers)

{

System.out.print("All elements in reverse order: ");

for (int i = randomNumbers.length - 1; i >= 0; i--)

{

System.out.print(randomNumbers[i] + " ");

}

System.out.println();

}

public static void firstLast(int[] randomNumbers)

{

System.out.print("First and last elements are: ");

System.out.print(randomNumbers[0] + " " + randomNumbers[randomNumbers.length - 1]);

System.out.println();

}

public static void main(String[] args)

{

// create instance of Random class

Random rand = new Random();

System.out.print("Array: ");

int[] randomNumbers = new int[10];

for (int i = 0; i < randomNumbers.length; i++)

{

randomNumbers[i] = rand.nextInt(100);

System.out.print(randomNumbers[i] + " ");

}

System.out.println();

indexEven(randomNumbers);

evenelement(randomNumbers);

reverseOrder(randomNumbers);

firstLast(randomNumbers);

}

}

Explanation:

8 0
3 years ago
Why and how of computers
makkiz [27]

Answer:

?

Explanation:

3 0
2 years ago
Which file types have exe and png as their extensions?
svlad2 [7]

Answer:

PNG are for photos and exe are for programs

6 0
2 years ago
Other questions:
  • Why computers are called "COMPUTER"?
    12·1 answer
  • True or false An electronic form uses input fields in which the user can enter data from their own computer and then transmit t
    10·1 answer
  • Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should repo
    13·1 answer
  • What does the term World Wide Web refer to?
    5·2 answers
  • What does limited access to a document mean?
    14·2 answers
  • Which group on the Home Tab allows you to add shapes to a PowerPoint slide?
    9·2 answers
  • Higher-speed Ethernet technologies use an electronic device known as a Hub rather than a switch True/False
    15·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a numbe
    8·1 answer
  • Assume a future where security counter measures against DoS attacks are much more widely implemented than at present. In this fu
    7·1 answer
  • Class 10 computer unit 1 all excersise​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!