hello guys im tryingg to write a program which will generate an aeiou grid...if the program finds two consecutive vovels in a sentence then it will thake the first vowel as the row and second one as the column reference ...and do a +1 in that location i seem to have written the program but it is not doing a plus one at any possition .... can u pls help me debug heere is the my code

import java.io.*;
class aeiou
{
public static void main()throws IOException
{ 

InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("input a string");
String str =br.readLine();
int a=0,e=1,i=2,o=3,u=4;
int l=str.length();
int arr[][]=new int[5][5];
for(int j=0;j<l-1;j++)
{
if(str.charAt(i)=='a'||str.charAt(i)=='e'||str.charAt(i)=='i'||str.charAt(i)=='o'||str.charAt(i)=='u')
if(str.charAt(i+1)=='a'||str.charAt(i+1)=='e'||str.charAt(i+1)=='i'||str.charAt(i+1)=='o'||str.charAt(i+1)=='u')
{
            if(str.charAt(i)=='a'&&str.charAt(i+1)=='a')
arr[a][a]++;if(str.charAt(i)=='a'&&str.charAt(i+1)=='e')
arr[a][e]++;if(str.charAt(i)=='a'&&str.charAt(i+1)=='i')
arr[a][i]++;if(str.charAt(i)=='a'&&str.charAt(i+1)=='o')
arr[a][o]++;if(str.charAt(i)=='a'&&str.charAt(i+1)=='u')
arr[a][u]++;if(str.charAt(i)=='a'&&str.charAt(i+1)=='a')
arr[e][a]++;if(str.charAt(i)=='e'&&str.charAt(i+1)=='e')
arr[e][e]++;if(str.charAt(i)=='e'&&str.charAt(i+1)=='i')
arr[e][i]++;if(str.charAt(i)=='e'&&str.charAt(i+1)=='o')
arr[e][o]++;if(str.charAt(i)=='e'&&str.charAt(i+1)=='u')
arr[e][u]++;if(str.charAt(i)=='e'&&str.charAt(i+1)=='a')
arr[i][a]++;if(str.charAt(i)=='i'&&str.charAt(i+1)=='e')
arr[i][e]++;if(str.charAt(i)=='i'&&str.charAt(i+1)=='i')
arr[i][i]++;if(str.charAt(i)=='i'&&str.charAt(i+1)=='o')
arr[i][o]++;if(str.charAt(i)=='i'&&str.charAt(i+1)=='u')
arr[i][u]++;if(str.charAt(i)=='i'&&str.charAt(i+1)=='a')
arr[o][a]++;if(str.charAt(i)=='o'&&str.charAt(i+1)=='e')
arr[o][e]++;if(str.charAt(i)=='o'&&str.charAt(i+1)=='i')
arr[o][i]++;if(str.charAt(i)=='o'&&str.charAt(i+1)=='o')
arr[o][o]++;if(str.charAt(i)=='o'&&str.charAt(i+1)=='u')
arr[o][u]++;if(str.charAt(i)=='o'&&str.charAt(i+1)=='a')
arr[u][a]++;if(str.charAt(i)=='u'&&str.charAt(i+1)=='e')
arr[u][e]++;if(str.charAt(i)=='u'&&str.charAt(i+1)=='i')
arr[u][i]++;if(str.charAt(i)=='u'&&str.charAt(i+1)=='o')
arr[u][o]++;if(str.charAt(i)=='u'&&str.charAt(i+1)=='u')
arr[u][u]++;
}
}
for(int j=0;j<5;j++)
{
for(int q=0;q<5;q++)
{
System.out.print(arr[j][q]);
}
System.out.println();
}
}
}

if you have any better suggestions then please suggest me some

Simple typo, confused i's and j's
line 14 et seq:

for(int [B][I]j[/I][/B]=0;[B][I]j[/I][/B]<l-1;[B][I]j[/I][/B]++)
  {
  if(str.charAt([B][I]i[/I][/B]) ... etc

Simple typo, confused i's and j's
line 14 et seq:

for(int [B][I]j[/I][/B]=0;[B][I]j[/I][/B]<l-1;[B][I]j[/I][/B]++)
  {
  if(str.charAt([B][I]i[/I][/B]) ... etc

thank you ...fixed it :D..i thought i had forgotten programming
:P

import java.io.*;
class aeiou
{
public static void main()throws IOException
{ 

InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("input a string");
String str =br.readLine();
int count_arr=0,l=str.length(),cnt=0;
int arr[][]=new int[5][5];
for(int j=0;j<l-1;j++)
{
if(str.charAt(j)=='a'||str.charAt(j)=='e'||str.charAt(j)=='i'||str.charAt(j)=='o'||str.charAt(j)=='u')
if(str.charAt(j+1)=='a'||str.charAt(j+1)=='e'||str.charAt(j+1)=='i'||str.charAt(j+1)=='o'||str.charAt(j+1)=='u')
{
if(str.charAt(j)=='a'&&str.charAt(j+1)=='a')arr[0][0]++;
if(str.charAt(j)=='a'&&str.charAt(j+1)=='e')arr[0][1]++;
if(str.charAt(j)=='a'&&str.charAt(j+1)=='i')arr[0][2]++;
if(str.charAt(j)=='a'&&str.charAt(j+1)=='o')arr[0][3]++;
if(str.charAt(j)=='a'&&str.charAt(j+1)=='u')arr[0][4]++;
if(str.charAt(j)=='e'&&str.charAt(j+1)=='a')arr[1][0]++;
if(str.charAt(j)=='e'&&str.charAt(j+1)=='e')arr[1][1]++;
if(str.charAt(j)=='e'&&str.charAt(j+1)=='i')arr[1][2]++;
if(str.charAt(j)=='e'&&str.charAt(j+1)=='o')arr[1][3]++;
if(str.charAt(j)=='e'&&str.charAt(j+1)=='u')arr[1][4]++;
if(str.charAt(j)=='i'&&str.charAt(j+1)=='a')arr[2][0]++;
if(str.charAt(j)=='i'&&str.charAt(j+1)=='e')arr[2][1]++;
if(str.charAt(j)=='i'&&str.charAt(j+1)=='i')arr[2][2]++;
if(str.charAt(j)=='i'&&str.charAt(j+1)=='o')arr[2][3]++;
if(str.charAt(j)=='i'&&str.charAt(j+1)=='u')arr[2][4]++;
if(str.charAt(j)=='o'&&str.charAt(j+1)=='a')arr[3][0]++;
if(str.charAt(j)=='o'&&str.charAt(j+1)=='e')arr[3][1]++;
if(str.charAt(j)=='o'&&str.charAt(j+1)=='i')arr[3][2]++;
if(str.charAt(j)=='o'&&str.charAt(j+1)=='o')arr[3][3]++;
if(str.charAt(j)=='o'&&str.charAt(j+1)=='u')arr[3][4]++;
if(str.charAt(j)=='u'&&str.charAt(j+1)=='a')arr[4][0]++;
if(str.charAt(j)=='u'&&str.charAt(j+1)=='e')arr[4][1]++;
if(str.charAt(j)=='u'&&str.charAt(j+1)=='i')arr[4][2]++;
if(str.charAt(j)=='u'&&str.charAt(j+1)=='o')arr[4][3]++;
if(str.charAt(j)=='u'&&str.charAt(j+1)=='u')arr[4][4]++;
}
}
System.out.println('\t'+"a"+'\t'+"e"+'\t'+"i"+'\t'+"o"+'\t'+"u");
print(count_arr,'a',arr);count_arr++;
print(count_arr,'e',arr);count_arr++;
print(count_arr,'i',arr);count_arr++;
print(count_arr,'o',arr);count_arr++;
print(count_arr,'u',arr);count_arr++;
}
static void print(int a,char b,int arr[][])
{
System.out.print(b);
for(int j=0;j<5;j++)
{
System.out.print('\t');
System.out.print(arr[a][j]);
}
System.out.println();
System.out.println();
System.out.println();
}
}

here is my new and modified post ...any way to make it shorter

Shorter?
I would have a little method that takes a char as parameter and returns an int, 0 - 4, saying which vowel the char was, -1 if it wasn't a vowel.
Now I can loop thru the input getting these values for the current and next char. If both are >= 0 then I can use those as the indices for incrementing the arr array. That will remove the need for all that horrible duplicated code on lines 1-42

This article has been dead for over six months. Start a new discussion instead.