0

i have an issue in a section of my application, and i hope you help me with it, first i'll explain how it should work

i have a stable table (url below):

note (math is not useful with the table,we should pickup the results)

-

open up the table

-

how does it work:

first of all i will write a word, (a word example: power), it will be stored to a String, the app will send it to a method to analyzing it and assigning a number to each letter of that word (power), after that the method will send a String of numbers (assigned numbers of power) to the final method, the final method will work with these numbers(a numbers example: 89649) depending on the above table restricted by a rule, the rule is (check each number with the next number on of it, the first number will be vertical, second will be horizontal) finally pickup and assign the results from the table to different variables.

example (89649):

first two numbers (vertical 8) (horizontal 9) result = 72

second two numbers (vertical 9) (horizontal 6) result = 6

etc.

my method code:

   public String numbersTable(String aNumbers){

NL = aNumbers.length();     //NL = numbers length
int[] Re = new int [NL];    //Re = Results
int[] arrNums = new int [NL]; //arryNums = an array to assign numbers in it (the numbers of aNumbers String above)

// converting from Character to String to Integer and assigning numbers to the array using for loop
for (int lop1 = 0; lop1 < NL; lop1++){
temp = Character.toString(aNumbers.charAt(lop1));       
arrNums[lop1] = Integer.parseInt(temp);
}


for (int lop2 = 0; lop2 < NL ;lop2 ++){
if (arrNums[lop2] == 5 && arrNums[lop2+1] == 5){Re[lop2] = lop2;
JOptionPane.showMessageDialog(null,Re[lop2]+" lop number"+lop2);
} 
else {}    

}


return R_1+"";
}

the issues :

1- the app does not know the table to figure out what is the result(yes if we have kind of math), so how can i make it search throw that table

2- in the second loop, i have a problem with the (NL), to check one by one throw the arrNums, the loop should start depending on (NL), but if (NL) less than 9, so it wouldn't do it, and if i make it like this

for (int lop2 = 0; lop2 < 10;lop2 ++)

i'll have error because the length does not much the loop times.

help me please

4

0 に答える 0