top of page
Click here to go to the home page of AskTheCode.

Problem: 'Is It You, Cody?' in Java | AskTheCode

Team ATC

Asked By: Crystal | Problem solving in Java | Problems related to Strings in Java | Ask The Code

 

Problem:

Is It You, Cody? Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct.

Now, will you take on this task?


Input Sample:

c O D y

Output Sample:

Correct


Code:


import java.util.Scanner;

public class solution_IIY_Cody{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);


String a = sc.next();

String b = sc.next();

String c = sc.next();

String d = sc.next();

a = a+b+c+d;

String s = "cody";

if (a.toLowerCase().equals(s)) {

System.out.println("Correct");

}

else{

System.out.println("Wrong");

}

}

}


Recent Posts

See All

Comentarios


bottom of page