Jim would like to send a secret message to a friend using a


Problem:

Jim would like to send a secret message to a friend using a sequence of words followed by a sequence of integers. Jim knows this secret message could be easily decoded, but it a first attempt to use cryptography for privacy purposes. The first integer is an index into the first word for one character. The 2nd integer is an index into the 2nd word for a 2nd character. This only works for a secret message that has exactly 5 characters. Write a Java program that hides a message using these two test cases with a dialog that looks like either one of these two dialogs:

Dialog 1

Enter five words: cheap energy can cause problems

Enter five integers: 4 2 1 0 5

Secret message: peace

  • Assume the index for each String is in range of 0 through the length() of the string - 1.
  • Send five next messages to the Scanner object to get five separate words, the first being:

String word1 = keyboard.next();

  • Send five nextInt() messages to the Scanner object to get five separate integers.

Solution Preview :

Prepared by a verified Expert
Macroeconomics: Jim would like to send a secret message to a friend using a
Reference No:- TGS01471812

Now Priced at $30 (50% Discount)

Recommended (90%)

Rated (4.3/5)