1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mylen [45]
3 years ago
15

This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether

a message is to be encoded or decoded, and then prompts the user to enter the message. A blank space is used to separate each word in the message, and a period (.) is used to denote the end of a sentence. Separate methods must be used to encode and decode the input message. The coding scheme is very simple: the code
Computers and Technology
1 answer:
Lilit [14]3 years ago
8 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class EncodeDecodeMessage {

public static String encode(String str) {

String result = "";

char ch;

for(int i = 0; i < str.length(); ++i) {

ch = str.charAt(i);

if(Character.isLowerCase(ch)) {

result += (char)('a' + (25-ch+'a'));

} else if(Character.isUpperCase(ch)) {

result += (char)('A' + (25-ch+'A'));

} else {

result += ch;

}

}

return result;

}

public static String decode(String str) {

return encode(str); // since the scheme is same, we can use encode for decode

}

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("1. Encode, 2. Decode. Enter your choice: ");

int choice = in.nextInt();

in.nextLine();

if(choice == 1) {

System.out.print("Enter sentence to encode: ");

String line = in.nextLine();

System.out.println("Encoded string is: " + encode(line));

} else if(choice == 2) {

System.out.print("Enter sentence to decode: ");

String line = in.nextLine();

System.out.println("Decoded string is: " + decode(line));

}

}

}

You might be interested in
What will the "background-color" of the "topButton" be when the program is finished running?
Lelu [443]

Answer:

Blue

Explanation:

set_Property - (topButton), (#background-color), (orange)

set_Property - (bottomButton), (#background-color), (red)

set_Property - (topButton), (#background-color), (blue)

set_Property - (bottomButton), (#background-color), (green)

Here, the background color for the 'topButton' would be "blue"  when the program is finished running, as it is the last task, the topButton would be set to or it is the last thing that will run for the button.

6 0
2 years ago
Differentiate between tabular and column form layout​
NeTakaya

In tabular form the data is displayed in a table layout following a continuous series of records. In this almost all the records are displayed in a single layout. While in columnar form the data is displayed one record at a time.

6 0
2 years ago
This is a graded practice activity. This is not an actual quiz.
Lerok [7]

Answer:

0

Explanation:

x=27

y=5

22+(27-5)

22+(22)

0

8 0
1 year ago
What is a computer network that provides connectivity in a geographic area or region larger than that covered by a local area ne
lina2011 [118]

Answer:

The correct answer for the given question is "Metropolitan Area Network"

Explanation:

The metropolitan area network connect the user with a geographic area of the size of  metropolitan area.Metropolitan area network connect LAN i.e " local area network " to a single larger network thats provide efficient  connection to the WAN network.Their are many advantage to use metropolitan area network which are mention above .

  • Provides the better security then other network.
  • Cheaper lost when we connect MAN with WAN.
  • If we use MAN network then data will be fastly transferred.
6 0
3 years ago
On a router configured to use RIP, the number of routers a packet must travel between before it reaches its destination is calle
11111nata11111 [884]

Answer:

metric

hop count

Explanation:

6 0
3 years ago
Other questions:
  • Which computer port transmits audio and video without the need for compression?
    6·1 answer
  • To add text into a SmartArt graphic, a user will need to _____.
    14·1 answer
  • what is the primary way to access applications in windows 8? a. control panel b. start menu c. desktop tiles d. context menu
    7·1 answer
  • WILL GIVE BRAINLIEST TO FIRST AND BEST ANSWER!
    10·1 answer
  • From which type of data storage does the CPU load information for processing during normal operation?
    14·1 answer
  • Cuales son las paginas web​
    12·1 answer
  • PLEASE HELP I mainly only need the answer for 4.
    5·1 answer
  • Who wants brainlyest! NO LINKS how do you message someone on brainly
    10·2 answers
  • I need to send this in ASAP
    6·2 answers
  • Why do you want to work from our company?​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!