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
Which activity is performed during high-level design in the V-model?
SVETLANKA909090 [29]

Answer:

understanding component interaction

4 0
2 years ago
PLEASE HELP ASAP i will mark brilliant
Ray Of Light [21]
1. Cyberbullying
2.Confide in an adult you trust, such as a teacher or a parent
3.It is easy to miscommunicate  and escalate the situation in an online environment

Cyberbully hurts people, so NEVER post something that could hurt someone's feelings

Hope this helps!
3 0
3 years ago
Read 2 more answers
What is professionalism and unprofessionalism in the work place?​
Dmitrij [34]

Answer:

Professionalism means communicating effectively and appropriately and always finding a way to be productive. Employers want new workers to be responsible, ethical, and team oriented, and to possess strong communication, interpersonal, and problem solving skills. Wrap these skills up all together and you've got professionalism.

There are many types of unprofessional behavior in the workplace, which include habitual tardiness, absence, harassment or bringing personal issues to the job. These behaviors can cause disruption to the company as a whole, which means they should be dealt with as soon as possible.

8 0
2 years ago
____ is the study of how computers can potentially improve without human programming.
Advocard [28]

Answer:

Machine Learning and/or Artificial Intelligence (AI)

5 0
1 year ago
Consider the training requirements of a space operations specialist. The first step in the training process is obtaining a gener
Tamiku [17]

Answer:

Command Operations

Explanation:

Space Operation specialist requires special training for aircraft and its operations along with satellite controls. Initially when a graduate joins the training he is required to understand command operations of aircraft. He can then use his skills to learn command operation of spacecraft and then will be promoted to learn satellite controls.

6 0
2 years ago
Other questions:
  • Technology progresses so new needs can be satisfied.<br><br> A. true<br><br> B. false
    12·2 answers
  • Ng/ Computer Applications - Office 2016 - EL3520 A
    13·1 answer
  • Jeremy has created a document that has images and a chart. The chart has to be updated manually, and double-clicking on the char
    15·1 answer
  • What is processing requirement in computer?
    11·1 answer
  • Which of the following is true for an API? I. Allows different devices to connect with each other II. Allows for Interactivity b
    15·1 answer
  • Select the examples of common Arts, A/V Technology, and Communication employers. Check all that apply.
    10·2 answers
  • Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual whi
    9·1 answer
  • Fill in the blanks to complete a summary of this part of the passage. For the power of Patents
    6·2 answers
  • What is the output for the following code?<br><br> print (5*4+5)
    11·1 answer
  • Which directory stores the cron configuration file?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!