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
cricket20 [7]
3 years ago
14

Write a program that produces a Caesar cipher of a given message string. A Caesar cipher is formed by rotating each letter of a

message by a given amount. For example, if your rotate by 3, every A becomes D; every B becomes E; and so on. Toward the end of the alphabet, you wrap around: X becomes A; Y becomes B; and Z becomes C. Your program should prompt for a message and an amount by which to rotate each letter and should output the encoded message.

Computers and Technology
1 answer:
PilotLPTM [1.2K]3 years ago
8 0

Answer:

Here is the JAVA program that produces Caeser cipher o given message string:

import java.util.Scanner;  //to accept input from user

public class Main {  

   public static void main(String args[]) {  //start of main function

       Scanner input = new Scanner(System.in);  //creates object of Scanner

       System.out.println("Enter the message : ");  //prompts user to enter a plaintext (message)

       String message = input.nextLine();  //reads the input message

       System.out.println("Enter the amount by which by which to rotate each letter : ");  //prompts user to enter value of shift to rotate each character according to shift

       int rotate = input.nextInt();  // reads the amount to rotate from user

       String encoded_m = "";  // to store the cipher text

       char letter;  // to store the character

       for(int i=0; i < message.length();i++)  {  // iterates through the message string until the length of the message string is reached

           letter = message.charAt(i);  // method charAt() returns the character at index i in a message and stores it to letter variable

           if(letter >= 'a' && letter <= 'z')  {  //if letter is between small a and z

            letter = (char) (letter + rotate);  //shift/rotate the letter

            if(letter > 'z') {  //if letter is greater than lower case z

               letter = (char) (letter+'a'-'z'-1); }  // re-rotate to starting position  

            encoded_m = encoded_m + letter;}  //compute the cipher text by adding the letter to the the encoded message

           else if(letter >= 'A' && letter <= 'Z') {  //if letter is between capital A and Z

            letter = (char) (letter + rotate);  //shift letter

            if(letter > 'Z') {  //if letter is greater than upper case Z

                letter = (char) (letter+'A'-'Z'-1);}  // re-rotate to starting position  

            encoded_m = encoded_m + letter;}  //computes encoded message

           else {  

         encoded_m = encoded_m + letter;  } }  //computes encoded message

System.out.println("Encoded message : " + encoded_m.toUpperCase());  }} //displays the cipher text (encoded message) in upper case letters

Explanation:

The program prompts the user to enter a message. This is a plaintext. Next the program prompts the user to enter an amount by which to rotate each letter. This is basically the value of shift. Next the program has a for loop that iterates through each character of the message string. At each iteration it uses charAt() which returns the character of message string at i-th index. This character is checked by if condition which checks if the character/letter is an upper or lowercase letter. Next the statement letter = (char) (letter + rotate);   is used to shift the letter up to the value of rotate and store it in letter variable. This letter is then added to the variable encoded_m. At each iteration the same procedure is repeated. After the loop breaks, the statement     System.out.println("Encoded message : " + encoded_m.toUpperCase()); displays the entire cipher text stored in encoded_m in uppercase letters on the output screen.

The logic of the program is explained here with an example in the attached document.

You might be interested in
Which best describes IMEI?
Delicious77 [7]

Answer:

A unique identifier for a mobile phone

Explanation:

There are different codes and tracking number assigned to different devices such as laptop, mobiles and other devices. The purpose of this task is to make sure the security of device in all aspects. The tracking number that is used to track mobile phone is named as IMEI that stands for International Mobile Equipment Identity.

IMEI is the the unique identity of mobile phone device that consists of 15 digits. It is the unique number that is assigned to phones.

8 0
3 years ago
You work as a Network Administrator for wwwpany Inc. You have suspected a bad driver or perhaps malware. Which of the following
vichka [17]

Answer:

Explanation:

There is a solution called ETA (Encrypted Traffic Analytics) this is a security advanced network that helps us to identify malware between the encrypted data, but with this tool is no necessary to break any protection and privacy chain.

This technology use machine learning to read all the traffic without deciphering it, in this way we can detect a difference between reliable and malicious traffic.

En windows we can use Microsoft Security Essentials like antivirus and detect virus, we can use Process Explorer, analyze the traffic, we can use Microsoft Network Monitor.

8 0
3 years ago
Describe the benefits of having an operational data warehouse (DWH), and the challenges of operating a DWH repository.
kvasek [131]

Answer:

The benefits of having the operational data ware-house are as follows:

  • The single operational warehouse typically support various tactical and the strategical decisions.  
  • It is subject oriented,volatile and integrated data warehousing in the system.
  • The warehousing mainly allow the system to process the large complex data in more efficient manner.
  • The operational warehouse are basically implemented for many business purposes.

The challenges of the operational warehouse repository are as follows:

  • In the operational data warehouse there is large number of user expectations.
  • The cost is the main challenge while designing the operational data warehousing as, it required efficient system in low cost.
  • Choosing the efficient and correct type of the warehouse is the big challenge.

5 0
3 years ago
A museum is evaluating historical documents for authenticity, reviewing their physical condition, and categorizing them by subje
Natasha_Volkova [10]

The part of this process that could the museum automate easily is defining and assigning categories by subject.

<h3>What is Cloud backup?</h3>

Cloud backup is known to be a kind of service where  data and applications on a business's servers are known to be saved up and kept on a remote server.

Note that a lot of Businesses usually back up to their data to cloud so as to keep files and data in space and available when they need it  most especially in the times of a system failure, outage, etc.

Learn more  about museum  from

brainly.com/question/95815

6 0
2 years ago
Ergonomics is defined as
Scrat [10]

Answer:

B. The design and arrangement of items for efficiency and safety.  

Explanation:

6 0
3 years ago
Other questions:
  • Why will the standard replacement algorithms (LRU, FIFO, clock) not be effective in handling this workload for a page allocation
    11·1 answer
  • You can execute three main types of linux commands. what are they?
    8·1 answer
  • A computer hard disk starts from rest, then speeds up with an angular acceleration of 190 rad/s2 until it reaches its final angu
    10·2 answers
  • The systems development life cycle (SDLC) is the overall process of developing, implementing, and retiring information systems t
    9·1 answer
  • Network a0 is a process by which several protocols evolve to form a single product.
    7·1 answer
  • The browser feature which enables tabs to work independently from one another so if one crashes, the others may continue to work
    6·1 answer
  • Will give brainliest
    10·1 answer
  • Full form of NCP?............
    5·2 answers
  • Write a Python program (rainfall.py) to collect data and calculate the average rainfall over a period of years. The program shou
    11·1 answer
  • Given two objects represented by the tuples (22, 1, 42, 10) and (20, 0, 36, 8):
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!