Hey I am having a problem with this java program im trying to accomplish.... I know how to count the characters or letters in a word, but how do you count every other word and display that letter in a row. Im trying to do an encryption program for example if i input Hiehlrluo, it should display Hello. here is my code i have it coded to count the letters... Any help would be great.

 * @(#)Week_four_number_67.java
 * Week_four_number_67 application
 * @author 
 * @version 1.00 2012/2/2
 import javax.swing.JOptionPane;
public class Week_four_number_67 
    public static void main(String[] args) 
		String Sentence = JOptionPane.showInputDialog(null,"Please input Your encrypted Sentance");
		int count1 = 0;
    	for (int i = 0; i < Sentence.length(); i++) 
			if (Character.isLetter(Sentence.charAt(i))) 

Recommended Answers

All 4 Replies

well .. iterate over all the char's you have, and add all the chars that are on an odd place in the original String to the String you'll print later on.

i am understanding what you are saying, but can you Provide an example visually?

Take a piece of paper and write on it the input word and write underneath each letter of the word its position in the word, starting with 0 for the first letter. Then select the letters that are above the even numbers.

got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.