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

Can anyone help with this? It needs to be basic java. using next() and int. A Li

ID: 3648071 • Letter: C

Question

Can anyone help with this? It needs to be basic java. using next() and int.

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. The String charAt (int) method returns a character, but when using the + operator, the returned character is treated as if it were an int. So instead of concatenating five characters, it could add up to the numeric equivalents used to store the characters. Consider the following code that outputs 195 (97 for 'a' plus 98 for 'b'):" Placing a string literal up front fixes the problem. This code prints Secret message: ad So make sure you start your output with the label "Secret message: This forces charAt to return value to become the character you seek.

Explanation / Answer

please rate - thanks

import java.util.*;
class Crypto
{public static void main(String args[]){
Scanner in=new Scanner(System.in);
int[]nums=new int[5];
String[]words=new String[5];
String mess="";
int i;
System.out.print("Enter five words: ");
for(i=0;i<5;i++)
    words[i]=in.next();
System.out.print("Enter five integers: ");
for(i=0;i<5;i++)
    nums[i]=in.nextInt();
for(i=0;i<5;i++)
    mess=mess+words[i].charAt(nums[i]);
System.out.println("Secret Message: "+mess);
    }
}

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