hey
i have a little problem, how do i make this two triangle:
O
O O
O O O
O O O O
O
O O
O O O
O O O O
i have to get input from user, that part i have done.
but the problem is loops and how to print the result out.
each letter i justified to the left with 4.
great thanks to anyone that could help me.
public class Oppgave1d {
public static void main(String[]args) {
Scanner input = new Scanner(System.in);
System.out.print("Hvor mange linjer? ");
int linje = input.nextInt();
System.out.print("Hvilken bokstav? ");
char bokstav = input.next().charAt(0);
for (int i = 0; i < linje; i++) {
for (int j = 0; j < linje; j++)
System.out.printf("\n%-4S ", bokstav);
}
}
}