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
A network needs to be set up with 60 subnets. Given the IPv4 class C address 192.168.100.0, what subnet mask value should be use
d1i1m1o1n [39]
We are asked for the subnet mask and the total usable host. There are given values such as a network needs to be set up with 60 subnets given that the IPv4 class C address 192.168.100.0. The subnet mask is "255.255.255.0". The total host is "254".
6 0
3 years ago
________ are the primary means of authentication for a user's computer and other networks and servers to which the user may have
inn [45]

Answer:

The answer to this question is "Password".

Explanation:

In computer science, any User's computer and networks and server is secured with the password to access all we use the password. for example, if we want to access any WiFi system or any User's computer. Then we will insert the password. If the password is wrong so we can't access the WiFi system or User's computer. similarly, If we want to access any server so we must know about the password. Then we use the server and change it's setting.

So the password is the primary means of authentication for all User's.  

4 0
3 years ago
When we type there Is blue like thing blinking what's that called ​
taurus [48]

Answer:

a cursor? I think.

3 0
3 years ago
Read 2 more answers
15. What type of presentation includes information created in a different Office application?
blondinia [14]
 the answer to the question is a Embedded ( I just learned this like a month ago so im pretty sure it right :))
4 0
3 years ago
Help!!
Eduardwww [97]

the undo option is the right answer



8 0
2 years ago
Read 2 more answers
Other questions:
  • What leadership style involves the ideas of advice others
    6·1 answer
  • After a robbery, what is the purpose of conducting a neighborhood canvass?
    9·1 answer
  • A communications objective is:
    12·1 answer
  • Question 1 Multiple Choice Worth 5 points)
    10·1 answer
  • Consider the following C++ program in which the statements are in the incorrect order. Rearrange the statements so that itprompt
    6·1 answer
  • Radar devices are used by law enforcement to be sure that individuals are driving safely. They tell the officer how fast the veh
    12·1 answer
  • HELP PLEASE
    7·1 answer
  • Assert statements are a tool programmers employ to help them debug their code more efficiently.
    6·1 answer
  • PLEASE HELP WILL GIVE BRAINLIEST!!!’
    15·1 answer
  • Alice is watching a speech over the internet. what type of message is alice attending to?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!