Here are the instructions:
The int t contains an integer between 1 and 50 (inclusive). Write code that outputs the number in words and stores the result in the String inwords. For example, if t is 35 then inwords should contain "thirty five". "t" can be any number from 1 to 50.
int t = ; String inwords; String []wordnames = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "twenty", "thirty", "fourty", "fifty"}; String []multiplesOfTen = {"10", "20", "30", "40", "50"}; String []units = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; while (t <= 12){ while (units[t].length < 50){ System.out.print(wordnames[t]); } };
Another thing I've tried is this:
inwords = " "; String []wordnames = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "twenty", "thirty", "fourty", "fifty"}; String []multiplesOfTen = {"10", "20", "30", "40", "50"}; String []units = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}; while (t <= 12){ if (units[t] == Integer.toString(t)) System.out.println(units[t]); };