Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:30:23+00:00 2026-06-11T10:30:23+00:00

I need help with my chiper lab. My instructions are: Write a program that

  • 0

I need help with my chiper lab. My instructions are:

Write a program that accepts any number of strings as command-line
arguments and displays those strings encrypted with the Atbash cipher.
You program should be as modular as possible and use good object
oriented programming techniques. Your program must be thoroughly
documented using javadoc comments.

I have String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; that should encode strings so that A would return Z and B would return Y and so on. I did my cipher lab in Eclipse and it’s not running. I’m not sure what I’m doing wrong.

public class CaesarCipher {
  public static void main(String[] args) {
    CaesarCipher cc = new CaesarCipher();
  }

  public static final int ALPHASIZE = 26;
  public static final char [] alpha = {'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'};
  protected char[] encrypt = new char[ALPHASIZE];
  protected char[] decrypt = new char[ALPHASIZE];

  public CaesarCipher() {
    for (int i=0; i<ALPHASIZE; i++)
      encrypt[i] = alpha[(i + 3) % ALPHASIZE];
    for (int i=0; i<ALPHASIZE; i++)
      decrypt[encrypt[i] - 'A'] = alpha[i];
  }

  /** Encryption Method */
  public String encrypt(String secret) {
    char[] mess = secret.toCharArray();
    for (int i=0; i<mess.length; i++)
      if (Character.isUpperCase(mess[i]))
        mess[i] = encrypt[mess[i] - 'A'];
    return new String(mess);
  }

  /** Decryption Method */
  public String decrypt(String secret) {
    char[] mess = secret.toCharArray();
    for (int i=0; i<mess.length; i++)
      if (Character.isUpperCase(mess[i]))
        mess[i] = decrypt[mess[i] - 'A'];
    return new String(mess);
  }  
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:30:25+00:00Added an answer on June 11, 2026 at 10:30 am

    Try this:

    public class CaesarCipher {
    
        private static final int A = (int)'A';
        private static final int Z = (int)'Z';
    
        public static void main(String[] args) {
            for (String s : args)
                System.out.println(new Encoder(s));
        }
    
        private static class Encoder {
            private String encoded;
            public Encoder(String s) {
                s = s.toUpperCase();
                StringBuilder sb = new StringBuilder();
                for (char c : s.toCharArray())
                    sb.append((char)(A + Z - (int)c));
                encoded = sb.toString();
            }
    
            @Override
            public String toString() { return encoded; }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help defining an expression to capture the four numerics per line that define
Need help with a query that I wrote: I have three tables Company id
Need help. I have Graph API code that uses an auth token with offline
I need help I'm using EJS javasript template to write a code snippet two
Need help with an error message that I just can't figure out. I am
Need help for that. I have a tabbar with 2 views, A and B
Need help with my simple PHP menu. I'd like to have something like that:
Need help making a script for Greasemonkey that will help me read forums more
Need help parsing... In my code, I have a method that returns url.getHost();. But
Need help with converting my VB.NET DTOs so that they can be used by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.