MCPcopy Index your code
hub / github.com/Hazrat-Ali9/Computer-Programming / main

Method main

Problem11.java:7–44  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

5public class Problem11 {
6
7 public static void main(String[] args) {
8 // TODO Auto-generated method stub
9 Scanner input = new Scanner(System.in);
10 int T = input.nextInt();
11
12 while (T < 1) {
13 T = input.nextInt();
14 }
15 input.nextLine();
16 String[] inputs = new String[T];
17
18 for (int i = 0; i < inputs.length; i++) {
19 String temp = input.nextLine();
20 int length = temp.length();
21 while (length > 50 || !isDigit(temp.charAt(0)) || !isDigit(temp.charAt(temp.length() - 1))
22 || !isValid(temp)) {
23 temp = input.nextLine();
24 length = temp.length();
25 }
26 inputs[i] = temp;
27 }
28 input.close();
29
30 for (int i = 0; i < inputs.length; i++) {
31 StringBuilder myString = new StringBuilder(inputs[i]);
32
33 for (int j = 1; j < myString.length() - 1; j++) {
34 if (myString.charAt(j) == 'R') {
35
36 myString.setCharAt(j, myString.charAt(j + 1));
37 } else if (myString.charAt(j) == 'L') {
38 myString.setCharAt(j, myString.charAt(j - 1));
39 }
40 }
41 System.out.println(myString);
42 }
43
44 }
45
46 static boolean isDigit(char m) {
47 if (m >= 48 && m <= 57) {

Callers

nothing calls this directly

Calls 2

isDigitMethod · 0.95
isValidMethod · 0.95

Tested by

no test coverage detected