Hi, i´m new to this forum and to java as well, my name is Matti and are from Iceland
i´m trying to make number sequence with one TextArea and one Button, using '\n' and '\t'
the result should look like this:
1 1 1
2 3 4
3 5 9
. . .
. . .
. . .
15 29 225
row 1: line number, row 2: odd number, and row 3: is sum of the numbers in row 2 1 - 1+3 - 1+3+5 and so on
this is what i got so far:
thanks and regardsimport java.applet.Applet; import java.awt.*; public class talnarod extends Applet { TextArea Ttafla; Button Bstart; int i, a, b, c; public void init() { Bstart = new Button("Start"); Ttafla = new TextArea(15,25); this.add(Bstart); this.add(Ttafla); } public boolean action(Event e, Object o) { if (e.target == Bstart) { for (a=1; a <= 15; a++) // here is the column 1: number 1 to 15 { for(b=1; b <= a; b++) // here is were i fail, column 2: odd numbers 1 to 29 { if( b % 2 != 0) // and after this i need column 3: sum of the numbers in column 2 Ttafla.appendText("" + a + '\t' + b + '\n'); } } return true; } return false; } }
Matti