As i really like Programming and i like to program in my free time so i was trying to create a code in which the output would look like an x. Something like this.
x x
x x
x
x x
x x
So i wanted the user to input the height of the "x". This is the code i have so far and i really don't know how to move on. I just need a hint or if anyone can tell me where i went wrong.
import java.util.Scanner;
public class x{
public static void main(String[] args){
Scanner kbd = new Scanner(System.in);
int height;
System.out.print("Enter the height of the X: " );
height = kbd.nextInt();
for (int i = 1; i <= height; i++){
for (int j = 1; j <= height; j++) {
if(i ==j || j+i == height + 1)
System.out.println("x");
else
System.out.print(" ");
}
}
}
}
xinSystem.out.println("x");correct this.<=, so for this particular use case it does not matter.