ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 May 2017 My Price 9.00

public class task3

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:

  • Functionprint_codedtakes three arguments, calledword, sources, targets. They are all strings.
  • Functionprint_codedprocesses the letters ofwordone by one, in the order in which they appear inword. For every such letter X, the function processes X as follows:
    • If X is equal to the character at position P ofsources, then the function prints the character at position P oftargets.
    • Otherwise, the function prints X.

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...

Answers

(11)
Status NEW Posted 26 May 2017 03:05 AM My Price 9.00

-----------

Attachments

file 1495770169-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)