Counting in Lojban, an artificial language developed over the last forty years, is easier than in most languages The numbers from zero to nine are:
0 no
1 pa
2 re
3 ci
4 vo
5 mk
6 xa
7 ze
8 bi
9 so
Larger numbers are created by gluing the digit together. For example, 123 is "pareci". Write a program that reads in a lojban string (representing a no. less than or equal to 1,000,000) and output it in numbers.
I don't know what happened; it seems that my programme is not checking the if statement if (str.substring(i-2,i) == q[ale])
. The rest of the loop is working fine. Any advice?
public class apple {
public static void main(String[] args) {
String [] q =
new String[10];//"no","pa","re","ci","vo","mk","xa","ze","bi","so"];
q[0] = "no";
q[1] = "pa";
q[2] = "re";
q[3] = "so";
q[4] = "ci";
q[5] = "vo";
q[6] = "mk";
q[7] = "xa";
q[8] = "ze";
q[9] = "bi";
//q[0] = "so";
int ln;
String str = "nocipa";
ln = str.length();
if (ln % 2 != 0)
{
System.out.println("Invalid number");
}
else
{
for (int i = 2; i <=ln-2; i = i + 2)
{
for (int ale = 0; ale < 9; ale++)
{
if (str.substring(i-2,i) == q[ale])
{
System.out.print("hello" );
}
}
}
}
}
}