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
vekshin1
3 years ago
12

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 se

quence. 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.
Computers and Technology
1 answer:
Pepsi [2]3 years ago
6 0

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;

You might be interested in
A __________ is a repository of data gathered from operational data and other sources that is designed to serve a particular com
VMariaS [17]
Data Mart is a smaller amount of data that is collected from a data warehouse.
8 0
3 years ago
Explain the concept of “survival of the fittest”
klasskru [66]

Answer:

i think thats a line from  the lorax

Explanation:

4 0
3 years ago
Write technical term of following statements: a.The set of programs to perform specific task. b.A feature of computer which tell
ExtremeBDS [4]

Answer:

a) Application software

d) Lady Augusta Ada Lovelace

b) (it may be versatility

6 0
3 years ago
Which of the following statements is true?
USPshnik [31]

Answer: (A) Computer science trends to deal with the data.

Explanation:

 The computer science basically tend to deal with the big data and data science as it is the emerging technologies with the upcoming years.

As, with the large amount of the data and high transmission rate we can easily developed new computing technologies with low budget.  

Data is basically defined as simple facts and figures and contain information that is very useful for developing the computing technology for study and processing the system.

Therefore, Option (A) is correct.

 

8 0
3 years ago
describe in your words how you think computer instruction design correlates with memory access ? the chapter also compares the d
AveGali [126]

The computers operate with great speed and only run one process at once. The fastest storage of all is the cache memory. Random Access Memory is in second place, and the hard drive is in third.

What is computers?
A computer is a digital electrical device that may be configured to automatically perform series of logical or mathematical operations (computation). Programs are generic sets of actions that can be carried out by modern computers. These apps give computers the ability to carry out a variety of tasks. A computer system is a "complete" system that comes with the peripheral devices, operating system, and hardware required for "full" functioning. This phrase may also apply to a collection of connected computers that work as a unit, such as a computer network a computer cluster.

Computers are used as control systems in a wide variety of industrial and consumer goods.

To learn more about computer
brainly.com/question/23275071
#SPJ4

8 0
1 year ago
Other questions:
  • Modify the program so that it can do any prescribed number of multiplication operations (at least up to 25 pairs). The program s
    10·1 answer
  • Can someone help me to give this guy brainliest the button is not there
    8·1 answer
  • Sam needs to create a spreadsheet for his coworkers. They will need to follow across a long row of data. Sam would like to make
    8·2 answers
  • Which term describes the order of arrangement of files and folders on a computer
    11·1 answer
  • Who wants to play nba 2k20 ps4
    5·2 answers
  • Suppose there are two hosts, S and R. They are communicating over a TCP connection, and R has already received from S al bytes f
    11·1 answer
  • You dad has given you his old digital scanner for your new computer. you plug it into the usb drive on your windows 8 computer b
    8·1 answer
  • Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline
    10·1 answer
  • Trong mạng internet, chúng tôi thay đổi công nghệ mạng LAN sang một công nghệ
    5·1 answer
  • Which of the following file formats allows you to share and save documents
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!