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
UkoKoshka [18]
4 years ago
10

"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. Ex: The following patterns yield a userScore of 4: simonPattern: R, R, G, B, R, Y, Y, B, G, Y
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";


System.out.println("userScore: " + userScore);

return;
}
}
Computers and Technology
1 answer:
kotykmax [81]4 years ago
5 0

Answer:

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+=1;

           }

           else

           {

               break;

           }

           

           

       }

       System.out.println("userScore: " + userScore);

 

    }

}

Explanation:

the string method charAt() is used to access each character of the string.

You might be interested in
he cost of an international call from New York to New Delhi is calculated as follows: connection fee,$1.99; $2.00 for the first
Vedmedyk [2.9K]

Answer:

// This program is written in C++ programming language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main ()

{

// Declare and initialize variables

float connecfee = 1.99;

float first3 = 2.00;

float addmin = 0.45; float cost;

int minutes;

// Prompt user for minutes talked

cout<<"Enter Number of Minutes: ";

cin>>minutes;

// Calculate cost;

if(minutes < 1)

{

cout<<"Enter a number greater than 0";

}

else if(minutes <= 3)

{

// Calculating cost for minutes less than or equal to 3

cost = connecfee + first3 * minutes;

cout<<"Talk time of "<<minutes<<" minutes costs "<<cost;

}

else

{

cost = connecfee + first3 * 3 + addmin * (minutes - 3);

cout<<"Talk time of "<<minutes<<" minutes costs "<<cost;

}

return 0;

}

// End of Program

8 0
4 years ago
Write a program that prompt the user to enter a bank balance. The balance entered by the user is read into a variable named bala
IRINA_888 [86]

Answer:

ertyuiopoijuhgfdsa hiyoufun tresdfghytrefgytredfg

Explanation:

look for the words

4 0
3 years ago
How does a push system differ from a pull system?
sergeinik [125]
Well if were talking about computer cooling, push system is like it seems pushing air into the computer, pull system is taking out air!! the best systems have both to get the optimal cooling possible!!!
3 0
3 years ago
Storage system that uses lasers to read data
tatuchka [14]

I believe it is an optical storage system that uses lasers to read data.

5 0
4 years ago
Read 2 more answers
When you set up a worksheet, you should use cell references in formulas whenever possible, rather than ____ values.
vovangra [49]

Answer:

Constant

Explanation:

One of the flexibility of worksheet is using cell references to get the value of a cell, this will make the overall formula update itself when cell values are changed, but when using a constant to make computation the formula is not keeping track of the contents of the cells for any change and this will make it a fresh work to get a value based on changed values.

4 0
3 years ago
Other questions:
  • Select the correct answer.
    8·2 answers
  • Imagine you are spending the weekend with your family in a location with ZERO technology- no phones, TV, computers, video, radio
    10·1 answer
  • "the firewall acts as a proxy for which two types of traffic? (choose two.)"
    14·1 answer
  • The World Wide Web is a program that allows you to search for information on the Internet.
    11·1 answer
  • You have just made changes to a GPO that you want to take effect as soon as possible on several user and computer accounts in th
    7·1 answer
  • A bank uses a computer program during the night to tell if the alarm should ring. Sensors in the bank set the following Boolean
    5·1 answer
  • A user has called the company help desk to inform them that their Wi-Fi enabled mobile device has been stolen. A support ticket
    13·1 answer
  • What are the three primary separation of concerns on the client-side of a dynamic web application? (Check all that apply)
    13·1 answer
  • Write a C++ Win32 Console Application that will use nested for loops to generate a multiplication table from 1 x 1 to 10 x 10. U
    12·1 answer
  • Which of the following is part of the cycle of dating violence
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!