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
kakasveta [241]
3 years ago
13

"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
Computers and Technology
1 answer:
Serhud [2]3 years ago
7 0

Answer:

        String simonSays = "ABCDEFGHIJ";

       System.out.println("Simon says: " + simonSays);

       

       int userScore = 0;

       

       System.out.print("Make your guess: ");

       Scanner obj = new Scanner(System.in);

       String guess = obj.next();

       

       for(int i=0; i<10; i++){

           if(guess.charAt(i) != simonSays.charAt(i)){

               break;

           }

           else{

               userScore++;

           }

       }

       System.out.println("Your score is " + userScore);

Explanation:

Even though  programming language is not specified, variable <em>userScore</em> implies that it should be in Java. Also, note that this code should be in your main function.

- <em>simonSays</em> variable is created to hold what Simon says and it is printed out.

- <em>userScore</em> variable is created to track user's score.

- <em>guess </em>variable takes the input written by the user. (I assumed users enter their choice. Otherwise, you should delete the Scanner part and just create another variable like String guess = "ABDFFHHH" )

- Then, we need to check if the user input is same as what Simon says using for loop. (Note that the loop is iterated 10 times because it is known Simon says 10 characters). if(guess.charAt(i) != simonSays.charAt(i), <em>charAt(i) </em>method is used to check each of the characters.

- If the characters are not same, the loop is terminated.

- If characters are same, <em>userScore</em> is increased by 1.

- After comparing all the characters, <em>userScore</em> is printed.

You might be interested in
ANSWER THIS CORRECTLY FOR BRAINLIEST
jeka57 [31]
The answer is https it is on Every url
6 0
3 years ago
Read 2 more answers
Jin needs to add a row into his spreadsheet, but he does not want to remove any existing data. Which combination of options shou
disa [49]

Answer:

b. insert > entire row

5 0
4 years ago
Read 2 more answers
When you are pasting an item, what choice will the Paste Options button offer you?
Monica [59]

The Paste Options button becomes available when you paste data into cells in Excel. The button appears just below the pasted selection. When you click the Paste Options button, you are presented with a list of options that determine how the data will be pasted into the cell. These options are also available on the Edit menu when you click Paste Special.

7 0
3 years ago
Which of the last step in conducting a URL search
kipiarov [429]
The user's browser renders the html code as a visual web page. A web page that we commonly see is structured by a bunch of 1 and 0. Rendering process allow the machine to interpret that 1 and 0 into the visual that we currently seeing Hope this helps. Let me know if you need additional help!
6 0
3 years ago
Why are id thieves hard to catch?
Paladinen [302]
Because they will change their identity and therefore they will never have the same name for a long period of time . So when they commit a crime , they will be difficult to find and catch
5 0
3 years ago
Other questions:
  • Redo Programming Exercise 16 of Chapter 4 so that all the named constants are defined in a namespace royaltyRates. PLEASE DONT F
    14·1 answer
  • Information storage:Select one:a. Eliminates the need for professional judgment.b. Keeps data in a form accessible to informatio
    9·1 answer
  • When you see a yield sign what do you do?
    8·1 answer
  • It's inventiveness uncertainty and futuristic ideas typically deals with science and technology ......what is it.
    8·1 answer
  • Earthquakes _____.
    9·2 answers
  • What the defination of electronics capacitor
    11·1 answer
  • Need help with photography
    12·1 answer
  • You have heard that it is possible to improve your computer's performance by storing all related files for a particular program
    9·1 answer
  • All NATE specialties are offered at two levels, A. journeyman and master. B. installation and service. C. apprentice and journey
    7·1 answer
  • What are examples of data duplication in flat files? Check all that apply.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!