0

I am not able to understand why the code is not inputting string for the first iteration while doing all the other things in same iteration.

package monk_take_walk;

import java.util.Scanner; import java.lang.String;

public class take_walk {

public static void main(String[] args) {
    // TODO code application logic here
    
     Scanner sc=new Scanner(System.in);
     System.out.println("Entr value for t");
     
    int t=sc.nextInt();
    //String str;
    int count;

    if(t>=1 && t<=10)
    { System.out.println("Value of T "+t);
        for(int i=0;i<t;i++)
        {
          
            System.out.println("Enter string no "+i);
            String str=sc.nextLine();
            System.out.println("String ="+str);
            int len=str.length();
            count=0;
            System.out.println("lenth = "+len);
            

            if(len>=1 && len<=100000)
            {
                for(int j=0;j<len;j++)
                {
                    str.toLowerCase();
                    char ch=str.charAt(j);
                    System.out.println("Current character "+ch);

                if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
                {
                    count++;
                    System.out.println("Curent count = "+count);
                }     
                }
            }
                
                
            System.out.println(count);

        }
           

        }
}

}

  • here is the output:::Entr value for t 3 Value of T 3 Enter string no 0 String = lenth = 0 0 Enter string no 1 ihji String =ihji lenth = 4 – Ishmeet Kaur Jul 01 '20 at 09:43

0 Answers0