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 3 of 3

Thread: Need help debugging

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help debugging

    Okay so I am making a code which will ask for a user input and then make a pattern out of it (case insensitive) the first code works however it only checks if the last variable in the string is the same to the current variable in the string

    		public String makePattern()
    		{
    			char[]
    					charInput=userInput.toCharArray();
    			        String output ="A";
    			        int codeValue=65;
    			        for(int increment = 1; increment <= charInput.length-1;increment++)
    			          {
     
    			        	if((int)charInput[increment] == (int)charInput[increment-1])
    			        	  {
     
    			        	  } 
    			        	      else 
    			        	      {
    			        		    codeValue = codeValue+1;
    			                  }
    			        	      output = output+Character.toString((char)codeValue);
     
    			          } 
    			                  return output;
    		}

    This next code totally breaks my code (it was my attempt to make it check the whole string instead of the last variable

    		public String makePattern()
    		{
    			char[]
    					charInput=userInput.toCharArray();
    			        String output ="A";
    			        int codeValue=65;
    			        for(int increment = 1; increment <= charInput.length-1;increment++)
    			          {
    			        	for(int checkString = 0; checkString < increment; checkString++)
    			        	{
    			        	if((int)charInput[increment] == (int)charInput[checkString])
    			        	  {
     
    			        	  } 
    			        	      else 
    			        	      {
    			        		    codeValue = codeValue+1;
    			                  }
    			        	      output = output+Character.toString((char)codeValue);
    			        	}      
    			          } 
    			                  return output;
    		}


  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: Need help debugging

    Hello.
    Can you plz be specific about what exactly are you trying to achieve?

    Syed.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help debugging

    The code is to ask for user input then make the first variable A and the second (if not equal to the variable at position 1) is supposed to be B example of sample inputs and outputs below.


    Input: Cat Output: ABC
    Input: Cool Output: ABBC
    Input: Football Output: ABBCDEFF
    Input: Inspiration Output: ABCDAEFGAHB

Similar Threads

  1. Error when debugging
    By Montrell79 in forum Java IDEs
    Replies: 0
    Last Post: March 14th, 2012, 06:07 PM
  2. Help with Error Debugging
    By bananasplitkids in forum Object Oriented Programming
    Replies: 3
    Last Post: March 9th, 2010, 10:16 AM
  3. Debugging
    By Altaf in forum Java IDEs
    Replies: 0
    Last Post: December 6th, 2009, 10:16 PM
  4. Debugging your program
    By helloworld922 in forum Debugging Tutorials
    Replies: 0
    Last Post: November 18th, 2009, 03:14 AM
  5. Debugging your program
    By helloworld922 in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: November 18th, 2009, 03:14 AM

Tags for this Thread