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
Why are men more exposed to mass media?
adell [148]

Answer:

because they like exploring

8 0
2 years ago
Read 2 more answers
In object-oriented analysis, an object is a member of a(n) _____, which is a collection of similar objects.
Advocard [28]

In object-oriented analysis, an object is a member of a CLASS, which is a collection of similar objects. It is a software engineering method.

<h3>Object-oriented analysis </h3>

Object-oriented analysis and design can be defined as a software engineering methodology.

This methodology (object-oriented analysis) is used to model a system as a particular group of interacting objects.

The object-oriented analysis is characterized due to the fact that objects are organized according to particular classes.

Learn more about object-oriented analysis here:

brainly.com/question/3522354

3 0
2 years ago
What color model should Joe use if he will be using an offset printing press?
EleoNora [17]

Answer:

CMYK

Explanation:

Monitors typically use RGB color (additive model — adding to make white), but offset printing uses CMYK pigments (subtractive color — subtracting from the existing white). Printed images have less visual range, saturation, and contrast than digital images, so in print, colors will usually appear darker and less vibrant.

6 0
2 years ago
The game often becomes stuck on landscape mode when tilting the device during gameplay, which cuts off some peripheral text. A w
ch4aika [34]

Answer:

The overview of the given situation is described in the explanation segment below.

Explanation:

  • Bug Severity seems to be the extent of influence that somehow a fault will have on the device, while its primary concern is indeed the command of severity that had already affected that same device.
  • You should consider this error as top importance as another framework hangs. I would say you may be lacking the configuration manager settings in your system.

Therefore the above is the right answer.

3 0
2 years ago
PLEASE HELP WITH MY COMPUTER
qaws [65]

Answer:

try powering it off the turn it back on

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • What is primary storage
    11·2 answers
  • A person who wants to buy a compact disc (cd) has just enough money to buy one, and chooses cd a instead of cd
    10·2 answers
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • Which operating system is a version of Linux?​
    13·1 answer
  • How to create a distribution list in outlook?
    7·1 answer
  • Please help me. Adnan also wants to add a photograph of a bridge. It is on another PowerPoint presentation that is open in a dif
    11·1 answer
  • Suppose Client A initiates a Telnet session with Server S. At about the same time, Client B also initiates a Telnet session with
    13·1 answer
  • If any one has mincraft on ps4 bedrock we can finish building a BIG city world all we need to put is a shop and money dispensers
    8·2 answers
  • When software is purchased, a _____ is being bought that gives the purchaser the right to use the software under certain terms a
    9·1 answer
  • Write a program that first reads a list of 5 integers from input. Then, read another value from the input, and output all intege
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!