import java.util.Scanner;
public class Question5 {
public static void main(String [] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a number: ");
int x = keyboard.nextInt();
System.out.print("Enter a char: ");
String c1 = keyboard.nextLine();
System.out.print("Enter a char: ");
String c2 = keyboard.nextLine();
printChars(x, c1, c2);
}
public static void printChars(int x, String c1, String c2) {
for (int i = 1 ; i <= x ; i++) {//
for (int z = 1 ; z <= x - i ; z++)//
System.out.print(c1);
for (int j = 1 ; j <= x ; j++)//
System.out.print(c2);
System.out.println();
}
}
}
it's the output i got now
----jGRASP exec: java Question5
Enter a number: 8
Enter a char:
Enter a char:
6
66666666
66666666
66666666
66666666
66666666
66666666
66666666
66666666
----jGRASP: operation complete.
but it shoud print like this
Enter a number: 5
Enter a char: %
Enter a char: $
% % % % %
% % % % $
% % % $ $
% % $ $ $
% $ $ $ $
$ $ $ $ $
please help me with this it's my first question on this forum