Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • String-Print a string character then extract user entered letter match with that word and append it as different word

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 47
    Answer it

    Problem-

    Its not entering the If loop in the code snippet, couldn't get what's wrong in this logic.

     

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
    
    
     */
    //first extract any userdefined letter from word and form a word
    package myfirst;
    
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.Scanner;
    
    /**
     *
     * @author kiit
     */
    
    public class Wrdpttrn {
        InputStreamReader inp = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(inp);
        StringBuilder sb=new StringBuilder();
         Scanner scanner = new Scanner(System.in);
        public void extractWord(String t){
            
            char arr[]=t.toCharArray();
           // boolean b;
           for(char c : arr){
                System.out.println("myfirst.Wrdpttrn.extractWord()"+c);
            
            }
               for(int i=0;i<=t.length();i++){
                   char c1 = scanner.next().charAt(0);
                System.out.println("Enter character from particular string sequence:"+c1);
               if(t.equalsIgnoreCase(String.valueOf(c1))){
               
                 //boolean b=true;
                    System.out.println("You have entered: "+c1);
                System.out.println("Enter character from particular string sequence1:");
                sb.append(c1);
                
                }
               // else{
                     //b=false;
               // }
               
                //if(b){
                    //System.out.println("Enter character from particular string sequence2:");
                    //sb.append(c1);
                    
                    
                    
                    
                }
               } 
        public static void main(String args[]){
            Wrdpttrn wp=new Wrdpttrn();
            wp.extractWord("shabana");
        }
        
    }


     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: