write a program (in Java/Eclipse to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.)
String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n";
input code:
output:
code:
public class Main
{
public static void main(String[] args) {
/*initialize message*/
String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY
BIDRHYO.\n";
/*travse in message*/
for(int i=0;i<msg.length();i++)
{
/*check letter or not*/
if(Character.isLetter(msg.charAt(i)))
{
/*print this is letter*/
System.out.print("?");
}
else
{
/*else print that Character*/
System.out.print(msg.charAt(i));
}
}
}
}
Get Answers For Free
Most questions answered within 1 hours.