Page 7 of 7 First ... 567
  • Jump to page:
    #91
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    47
    Rep Power
    0
    Originally Posted by NormR
    That is poorly documented code.
    The variable names could be more descriptive of their purpose.
    What value does dC contain?
    What are the variables a and b for?
    Some vars like a, b are Redundant, thought at program writing but maybe never used

    dC=is the charAt(i) a Consonant

    ....
    ....

    and alike.
  2. #92
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    What does the name dC mean? How can anyone reading the code understand what value it contains?
    strippedInput says something about what it contains

    Why aren't there any comments describing the logic of the code?

    If you want to post code for beginners you should make an effort to write good, documented code and not be sloppy like this code is.

    Comments on this post

    • Aurum84 agrees
  4. #93
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    47
    Rep Power
    0
    Originally Posted by NormR
    What does the name dC mean? How can anyone reading the code understand what value it contains?
    strippedInput says something about what it contains

    Why aren't there any comments describing the logic of the code?

    If you want to post code for beginners you should make an effort to write good, documented code and not be sloppy like this code is.
    Would this do in Some Way ?

    Code:
    import javax.swing.JOptionPane;
    public class AlternatingVowelsAndConsonants 
    {
    	public static void main(String[] args)
    	{
    		final String Vowel=
    				"aeiıou";
    		String userInput,not = "";
    		char currentChar;
    		int vow = 0, con = 0;
    		userInput = JOptionPane.showInputDialog(null, "Enter a word ");
    		String strippedInput = userInput.replaceAll("\\W", "");
    		String strippedInput1 = strippedInput.toLowerCase();
    		int c = strippedInput1.length();
    		boolean boo=true;	
    
     String str="yes";
     for(int i=0;i<strippedInput1.length()-1;i++){
    	currentChar = strippedInput1.charAt(i);
    	char currentCharPlus2=strippedInput1.charAt(i+1);
    	boolean currentIsVowel= Vowel.indexOf(currentChar)!=-1;
        boolean currentIsConsonant=Vowel.indexOf(currentChar)==-1;
    	boolean currentPlusIsVowel= Vowel.indexOf(currentCharPlus2)!=-1; 
    	boolean currentPlusIsConsonant=Vowel.indexOf(currentCharPlus2)==-1;
     	 if(currentIsConsonant && currentPlusIsConsonant){
    		 str="NOT";
    		 ;
    	 }
    	 	 if(currentIsVowel&&currentPlusIsVowel){
    		 str="NOT";
     ;	 } 
    }
    System.out.println(str);
    	}
    	}
Page 7 of 7 First ... 567
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo