Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Is this Caesar cipher optimal? PVP

  1. #1
    Member
    Join Date
    May 2019
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is this Caesar cipher optimal? PVP

    I have created this really simple cipher, do you have any recommendations on how to improve it or ideas how to create it differently?

    UPDATE: Not a caesar cipher!

    Thank you

    	String word="Hello";
    	word=word.toLowerCase();
    	for(int i=0; i<word.length(); i++) {
    		if(word.charAt(i)=='a'|| word.charAt(i)=='e'|| word.charAt(i)=='i'|| 
    		word.charAt(i)=='o'|| word.charAt(i)=='u') {
    			System.out.print(word.charAt(i));
    			System.out.print('p');  
    			System.out.print(word.charAt(i));
    		} else {
    			System.out.print(word.charAt(i)); 
    		}
    	}
    Last edited by DonnyWatts; May 19th, 2019 at 05:36 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Is this Caesar cipher optimal? PVP

    Can you explain the steps in the algorithm that you are trying to implement?
    Does the program's output match the expected output?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2019
    Posts
    25
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Is this Caesar cipher optimal? PVP

    String word = "Hello";
            word = word.toLowerCase();
            for (int i = 0; i < word.length(); i++) {
                char ch = word.charAt(i);
                if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
                    System.out.print(ch);
                    System.out.print('p');
                    System.out.print(ch);
                } else {
                    System.out.print(ch);
                }
            }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Is this Caesar cipher optimal? PVP

    @veretimothy what is the purpose of your post?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: May 22nd, 2013, 07:48 PM
  2. Caesar Encryption
    By andrew_m428 in forum The Cafe
    Replies: 1
    Last Post: October 4th, 2012, 10:59 PM
  3. [SOLVED] Double key Caesar Cipher (USING A STACK AND A QUEUE TO SHIFT LETTERS OF A STRING)
    By Medo Almasry in forum What's Wrong With My Code?
    Replies: 16
    Last Post: November 19th, 2011, 04:18 PM
  4. Encode and decode - Caesar cipher
    By siabanie in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2011, 06:25 PM
  5. Algorithm for Optimal Job Scheduling Contest
    By bart_bl in forum The Cafe
    Replies: 3
    Last Post: May 6th, 2011, 02:59 AM

Tags for this Thread