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
What is a term commonly used to describe the Python dictionary feature in other programming languages
Yakvenalex [24]

Explanation:

1) Easy to Learn and Use

Python is easy to learn and use. It is developer-friendly and high level programming language.

2) Expressive Language

Python language is more expressive means that it is more understandable and readable.

3) Interpreted Language

Python is an interpreted language i.e. interpreter executes the code line by line at a time. This makes debugging easy and thus suitable for beginners.

4) Cross-platform Language

Python can run equally on different platforms such as Windows, Linux, Unix and Macintosh etc. So, we can say that Python is a portable language.

5) Free and Open Source

Python language is freely available at offical web address.The source-code is also available. Therefore it is open source.

6) Object-Oriented Language

Python supports object oriented language and concepts of classes and objects come into existence.

7) Extensible

It implies that other languages such as C/C++ can be used to compile the code and thus it can be used further in our python code.

8) Large Standard Library

Python has a large and broad library and prvides rich set of module and functions for rapid application development.

9) GUI Programming Support

Graphical user interfaces can be developed using Python.

10) Integrated

It can be easily integrated with languages like C, C++, JAVA etc.

7 0
3 years ago
Write the definition of a method printGrade, which has a char parameter and returns nothing.The method prints on a line by itsel
o-na [289]

Answer:

The answer to this question can be given as:

Method Definition:

void printGrade(char x) //declare method with parameter.  

{

 

//method body

System.out.println("Grade: "+x);

 //print value in new line.

}

Explanation:

In the above method definition, we define a method that's name is already given in the question that is printGrade. This method does not return any value because its return type is void. In this method, we pass a char variable as a parameter. Then we define the method body in the method body we print the value of the char variable in the new line. To print the value in the new line we use the println function in java.

5 0
3 years ago
You have a server with two physical processors, each with four cores for a total of 8 cores. How many license packs must you buy
mafiozo [28]

Answer:

You must buy eight 2-core license packs, for a total of 16 core licenses.

Explanation:

Brainliest pls

3 0
2 years ago
Our tests will run your program with input 2, then run again with input 5. Your program should work for any input, though.
Dahasolnce [82]

Answer:

In Python:

numDays = int(input("Days: "))

print("Number of days: "+str(numDays)+"\n")

Explanation:

The program was written in Python and the explanation is as follows;

First, get the input for the number of days from the user

<em>numDays = int(input("Days: "))</em>

Next, print string "Number of days: " followed by the number input from the user and then newline

<em>print("Number of days: "+str(numDays)+"\n")</em>

<em>The character \n represents new line</em>

5 0
3 years ago
A(n) ______ is an output device that visually conveys text, graphics, and video information.
polet [3.4K]
The answer is Printer. hope this helped :)

3 0
3 years ago
Other questions:
  • If a suspect is not read his or her Miranda rights, then nothing the suspect says can be used at trial, even if the suspect volu
    11·1 answer
  • Host Y sends the first TCP ACK message for the transaction?<br><br> a. true<br><br> b. false
    9·1 answer
  • Which of the following is most likely to require use of a server, desktop, and industry-specific handheld computer, and is most
    8·1 answer
  • Identify the following as True or False: (1) Naive Bayes is a linear classifier. (2) SVMs are only usable when the classes are l
    8·1 answer
  • Alyson would like to see a list of all of the applications installed on her computer. What is the easiest way for her to do this
    8·1 answer
  • What is computer science ​
    5·1 answer
  • Which of the following is a method which can be used to delete a page from a publication?
    6·1 answer
  • One of the earliest computer networks was the ARPANET, developed in the early 1960s. The purpose of this network was to:
    13·2 answers
  • Ingredient Adjuster
    11·1 answer
  • Which terms would be found in search for "Mo*”? Check all that apply.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!