Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So Im just not sure how this works. I can do it with \"String aString =\" for ju

ID: 3648000 • Letter: S

Question

So Im just not sure how this works. I can do it with "String aString =" for just a single word but how do I use "next" command to use words as shown below.

3) A Little Cryptography
Write a Java program in Crypto.java that hides a message in five words. Use one of the characters in
the five input strings to spell out one new word. The single character comes from the associated integer in the 2nd
line of user input. Run your program with the following input. Also make up at least one other.

Example: Enter five words: cheap energy can cause problems

Enter five integers: 4 2 1 0 5

Secret message: peace

Explanation / Answer

class Crypto{ private static String[] words; private static String sent; private static String intString; public static void main(String[] args){ System.out.println("Enter five words:"); //reading input from the keyboard entered by the user Scanner scn = new Scanner(System.in); sent = scn.nextLine(); //splitting the entered sentence into words words = sent.split(); System.out.println("Enter five integers"); intString = scn.nextLine(); System.out.println("Secret message:"+secretMessage()); } public static String secretMessage(){ String curr = ""; for(int i = 0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote