Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exercise4v2 {
- public static void main(String [] args) {
- Scanner feed = new Scanner(System.in);
- // Asks user for dimensions of square
- System.out.println("Input desired height of the square");
- int width = feed.nextInt();
- int lines = width;
- do {
- for(int a=0; a<width; a++) {
- System.out.print("X");
- }
- width=0;
- }while(width>0);
- width=lines;
- System.out.println();
- System.out.print("X");
- //System.out.println(lines + "lines arvo");
- //System.out.print(width + "width arvo");
- while(lines>2) {
- do {
- for(int a=2; a<width; a++) {
- System.out.print(" ");
- }
- //System.out.print("w="+width);
- width--;
- }while(width>2);
- if(width==2) {
- System.out.print("X");
- System.out.println();
- }
- //System.out.print("w="+width);
- System.out.print("l="+lines);
- lines--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement