Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hmwrote like 200 lines of code, but I still seem to be lost on exactly what I

ID: 3617269 • Letter: X

Question

x.Hmwrote like 200 lines of code, but I still seem to be lost on exactly what I am suppose to do. I am attaching a pdf of the assignment I am suppose to do. From what I read, I understand that I am suppose to write a code using ceaser's cipher to encrypt and decrypt data. Also the input has to be a file. Also to do the encryption and decryption, I will have to use the ascii chart. The code that I wrote can do this encryption and decryption, but only with upper and lower case letters and spaces. Can someone show me how to do this using the ascii chart?? Also can you let me know exactly what I have to do? Thank you.

Here is my program so far:

import javax.swing.*;
import java.util.*;
import java.io.*;

public class decryption
{
public static void main(String[] args)
{
    boolean loop8 = true;
    int yes;
    yes = 0;
    while (loop8)
    {
      String try4 = JOptionPane.showInputDialog("Would you like to encrypt or decrypt?");
      if (try4.compareTo("encrypt")==0)
      {
        JOptionPane.showMessageDialog(null, "Ok");
        yes = 3;
      }else if (try4.compareTo("decrypt")==0)
      {
        JOptionPane.showMessageDialog(null, "Ok");
        yes = 4;
      }else
      {
        JOptionPane.showMessageDialog(null, "You can ONLY enter encrypt or decrypt");
      }
      boolean loop1 = true;
      int w;
      String input = JOptionPane.showInputDialog("Enter message: ");
      w = 1;
      while (loop1)
      {
        String[] alphabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        String message = input,token="";
        StringTokenizer st;
        st = new StringTokenizer(message, "");    
        message = "";
        while (st.hasMoreElements())
        {
          message += st.nextToken();
        }
        int len_message = message.length();
        String finish;
        String new_letter;
        new_letter = ("");
        finish = ("");
        if (yes == 3)
        {
          for (int i = 0; i < len_message; i++)
          {
            String letter = message.substring(i,i+1);
            if (letter.compareTo(" ") == 0)
            {
              new_letter = (" ");
            }      
            if (letter.compareTo("x") == 0)
            {
              new_letter = ("a");
            }
            else if (letter.compareTo("X") == 0)
            {
              new_letter = ("A");
            }
            if (letter.compareTo("y") == 0)
            {
              new_letter = ("b");
            }
            else if (letter.compareTo("Y") == 0)
            {
              new_letter = ("B");
            }
            if (letter.compareTo("z") == 0)
            {
              new_letter = ("c");
            }
            else if (letter.compareTo("Z") == 0)
            {
              new_letter = ("C");
            }
            else
            {
              int t = 0;
              while (t < 26)
              {
                if (letter.compareTo(alphabet[t]) == 0)
                {
                  new_letter = alphabet[t+w];
                  break;
                }
                else
                {
                  t = t + 1;
                }
        &nb

Explanation / Answer

please rate - thanks with ascii import java.util.*; public class untitled1 {public static void main(String [] args) {Scanner in=new Scanner(System.in); System.out.print("Enter number: "); int n=in.nextInt(); System.out.println(ascii(n)); } public static char ascii(int n) {return (char)n;       } }