Question
import java.util.Scanner; public class SimonSays { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String simonPattern; String userPattern; int userScore;
import java.util.Scanner;
public class SimonSays { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String simonPattern; String userPattern; int userScore; int i;
userScore = 0;
simonPattern = scnr.next(); userPattern = scnr.next();
/* Your solution goes here */
System.out.println("userScore: " + userScore);
return; } }
import java.util.Scanner; public class NestedLoop { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int userNum; int i; int j;
userNum = scnr.nextInt();
/* Your solution goes here */
} }
import java.util.Scanner; public class NestedLoops { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int numRows; int numColumns; int currentRow; int currentColumn; char currentColumnLetter;
numRows = scnr.nextInt(); numColumns = scnr.nextInt();
/* Your solution goes here */
System.out.println(""); } }
"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: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY 1 test passed All tests passed 1 import java.util.Scanner; 2 3 public class SimonSays { 4 public static void main (String [] args) { 5 Scanner scnr = new Scanner(System.in); 6 String simonPattern; 7 String userPattern; 8 int userScore; 9 int i; 10 11 user Score = 0; 12 13 simonPattern = scnr.next(); 14 user Pattern = scnr.next(); 15 16 \ * Your solution goes here */ 17 18 System.out.println("userScore: + userScore); Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 1 test passed 1 import java.util.Scanner; 2 public class NestedLoop { 3 public static void main (String [] args) { 4 Scanner scnr = new Scanner(System.in); 5 int user Num; 6 int i; 7 int j; 8 9 user Num = scnr.nextInt(); 10 11 \* Your solution goes here */ 12 13 } 14 } All tests passed Run Feedback? Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Use separate print statements to print the row and column. Ex: numRows = 2 and numColumns = 3 prints: 1A 1B 1C 2A 2B 2C 1 test passed All tests assed 1 import java.util.Scanner; 2 public class NestedLoops { 3 public static void main (String [] args) { 4 Scanner scnr = new Scanner(System.in); 5 int numRows; 6 int numColumns; 7 int currentRow; 8 int currentColumn; 9 char currentColumnLetter; 10 11 numRows = scnr.nextInt(); 12 numColumns = scnr.nextInt(); 13 14 * Your solution goes here */ 15 16 System.out.println(""); 17 } 18 } Run FeedbackStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started