'I am making an app which shows table of a number but it only shows last calculation, i want all the calculations from 1 to 10

CodeHi there, I am trying to make an app which shows the table of a number given by user. I am able to get only last answer of a table, for example, it only shows 5*10=50 but i want whole table from 1 to 10. For reference, I've also attached some images of the app. please help.



Solution 1:[1]

Here is simple solution for java developers

int a  = 1; //User Input
StringBuilder table = new StringBuilder();
for(int i = 1; i <= 10; i++) {
    table.append(a).append(" * ").append(i).append(" = ").append(a * i).append("\n");
}
String finalTable = table.toString();

Solution 2:[2]

i think your logic is wrong plz check you loop statement. If you want whole table result from 1 to 10 then you should start you loop from 1 to 10 with increment.

for(int i = 1; i < = 10; i++) {
            Log.d((input+" * "+i+" = "+ input * i );    
        }
Thanks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gulab patel
Solution 2 Krishna