C++ "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. 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:
Ex: The following patterns yield a userScore of 9:
simonPattern: RRGBRYYBGY
userPattern: RRGBBRYBGY
Result: Can't get test 2 to occur when userScore is 9
Testing: RRGBRYYBGY/RRGBBRYBGY
Your value: 4
Testing: RRRRRRRRRR/RRRRRRRRRY
Expected value: 9
Your value: 4
Tests aborted.

Answers

Answer 1

Answer:

In C++:

#include <iostream>

using namespace std;

int main(){

   int userScore = 0;

   string simonPattern, userPattern;

   cout<<"Simon Pattern: ";    cin>>simonPattern;

   cout<<"User Pattern: ";    cin>>userPattern;

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

       if(simonPattern[i]== userPattern[i]){

           userScore++;        }

       else{            break;        }

   }

   cout<<"Your value: "<<userScore;

   return 0;

}

Explanation:

This initializes user score to 0

   int userScore = 0;

This declares simonPattern and userPattern as string

   string simonPattern, userPattern;

This gets input for simonPattern

   cout<<"Simon Pattern: ";    cin>>simonPattern;

This gets input for userPattern

   cout<<"User Pattern: ";    cin>>userPattern;

This iterates through each string

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

This checks for matching characters

       if(simonPattern[i]== userPattern[i]){

           userScore++;        }

This breaks the loop, if the characters mismatch

       else{            break;        }

   }

This prints the number of consecutive matches

   cout<<"Your value: "<<userScore;


Related Questions

If we ignore the audio data in a video file, a video file is just a collection of many individual frames (i.e., images). What is the main reason that a video file can achieve a much higher compression ratio than a file that contains a single image file?

Answers

Answer:

It is compressing the video file to make it smaller, but doing so without actually losing any quality

Explanation:

The main reason for a video file that can achieve a much higher compression ratio than a file that contains a single image file is that it can reduce the size of the file without affecting its quality.

What is Video compression?

Video compression may be defined as a type of methodology that is significantly utilized in order to decline the size of a video file or alter the formatting of the video without compromising its quality.

The process of compression effectively permits you to reduce the number of storage resources that are needed to store videos and save costs. The importance of video compression includes smaller overall file sizes.

Therefore, the main reason for a video file that can achieve a much higher compression ratio than a file that contains a single image file is that it can reduce the size of the file without affecting its quality.

To learn more about Video compression, refer to the link:

https://brainly.com/question/28078112

#SPJ2

What is also known as a visual aid in a presentation?
A. background
B. animation
C. review
D. slide
E. template

Answers

Visual aids are defined as charts, pictures or images that help to make a point or enhance a presentation, so I would say B. animation.

Hope this helps!!

Answer:

it is d slide

Explanation:

Which of the statements below describe how to print a document?

Answers

Is there supposed to be a picture? We can’t see the options.

identify and explain 3 methods of automatically formatting documents​

Answers

Answer:

Three common automatic formatting for documents are...

Margin justification- where text is aligned to both the left and right margin- producing a neat page

Paragraph justification- where paragraphs are not split as they go over the page- but are moved to the next page in one piece.

Tabular justification- where text is indented or aligned at a 'tab stop'. - to emphasise a paragraph.

The 3 methods used in Microsoft word to auto format are; Margin Justification, Tabular Justification, Paragraph Justification

What is formatting in Microsoft Word?

In Microsoft word, there are different ways of formatting a text and they are;

Margin justification; This is a type of formatting where all the selected text are aligned to either the left or right margin as you go to a new page as dictated by the user.

Paragraph justification; This a type of auto formatting where paragraphs are not split as they go to a new page but simply continue from where they left off.

Tabular justification; This is a type that the text is indented or aligned at a 'tab stop' to possibly show a paragraph.

Read more about Formatting in Microsoft Word at: https://brainly.com/question/25813601

Other Questions
4 to the power of3 -(2+2to the power of 3) x 5 Write the equation of the line in slope-intercept form using y=mx+b Look at the image, read, and choose the option, with the correct words, that completes the sentence. (1 point)Boy eating a bananaEs Jason. 1. ________ come 2. ________.1. l 2. la banana1. Ella 2. la fresa1. l 2. la fresa1. Ella 2. la banana One of Jefferson's main reasons for purchasing the Louisiana Territory from France wasAhe worried that Napoleon would try to build an empire in AmericaBhe worried that Mexico would try to buy it firstCit gave the US more opportunities to trade with South AmericaDit gave the US more opportunities to trade with Native Americans Fill in the spaces and choose whether it is Que, Cual, or CualesEscogerSelect the correct option for each question.1. [ Select ] gato prefieres?2. [ Select ] son los postres para la fiesta?3. [ Select ] pelcula quieres ver?4. [ Select ] es tu nmero de telfono?5. [ Select ] estudias?Flag question: Question 2Question 25 ptsChoose the correct interrogative word.1. [ Select ] es tu fecha de cumpleaos?2. A [ Select ] hora naciste?3. [ Select ] es tu estado civil?4. En [ Select ] etapa de la vida estn tus padres?5. [ Select ] es una quinceaera? what type of government was the us after the industrial revolution Describe the government structure of Rome? Calculate the pH of each of the following aqueous solutions. (Enter your answers to two decimal places.) (a) 10.0 mL deionized water WebAssign will check your answer for the correct number of significant figures. 2.72 Incorrect: Your answer is incorrect. (b) 10.0 mL deionized water plus 5.0 mL of 0.10 M NaOH WebAssign will check your answer for the correct number of significant figures. (c) 10.0 mL deionized water plus 10.0 mL of 0.10 M NaOH WebAssign will check your answer for the correct number of significant figures. (d) 10.0 mL deionized water plus 15.0 mL of 0.10 M NaOH WebAssign will check your answer for the correct number of significant figures. A triangle has side lengths of 5a +3 inches and 2a +3 inches. If the perimeter of the triangle is 3a + 12 inches, which expression represents the length, in inches, of the third side of the triangle? in which types of cells are these structures found When a team agrees on the level of performance expected by each member, they have a _____.shared standardcollaborative effortunified commitmentteam structureTHE ANSWER IS SHARED STANDARD Which of the following scenarios shows someone who benefited from a choice made?A.Serena chose to take Mary Beths lunch money, so she spent the afternoon in detention.B.Lilly decided to eat the entire giant chocolate bunny and did not feel well for the rest of the day.C.Andrew chose to carpool every morning and was able to park in the front-row car pool section at school.D.Timothy decided to watch the game instead of study for his test, so he failed it the next day.Please select the best answer from the choices providedABCD Planet Fitness gym charges $15 per month plus $50 for a membership. TotalFitness gym charges $25 per month and no membership fee. After how many monthswould the total cost be the same for both gyms? Which of these groups is described by the points listed in the box?A)the Molly MaguiresB)the Knights of Laborthe American Federation of LaborD)the International Workers of the World The area of the triangle below is 23.4 square inches. What is the length of the base?6 in is the height DIEGO: Cmo vamos al centro?SANTIAGO: Vamos en Symbols , porque no quiero usar gasolina ni pagar nada. Where are chromosomes found in the human body what are chromosomes made of Plz help i will give It would be very nice if you could evaluate the expression for ya homie-63/(-7)+6 Plz help.............