The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
import java.util.Scanner;
public class task3
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String sources = "abcdefghijklmnopqrstuvwxyz";
String targets = "bcdefghijklmnopqrstuvwxyza";
while (true)
{
System.out.printf("Enter some word, or q to quit: ");
String word = in.next();
if (word.equals("q"))
{
System.out.printf("Exiting...n");
break;
}
print_coded(word, sources, targets);
System.out.printf("nn");
}
}
}
This is an incomplete program. The goal of the program is to take as input strings from the user, and then print out coded (encrypted) versions of those strings, by replacing each letter with another letter. Complete that program, by defining aprint_codedfunction, that satisfies the following specs:
Note that arguments sources and targets are hardcoded in the main function, the user cannot change those values. The user can only specify the value of word.
IMPORTANT: you are NOT allowed to modify in any way the main function.
This is an example run of the complete program:
Enter some word, or q to quit: hello ifmmp Enter some word, or q to quit: HELLO HELLO Enter some word, or q to quit: Arlington Asmjohupo Enter some word, or q to quit: Texas Tfybt Enter some word, or q to quit: q Exiting...
-----------