0

I want to help me to Write a program which will draw an “X” shape as shown in the figure below. Your program must consist of one class named “Picture”. In your main method you must declare and initialize some String variables which you will later use in a print statement to get this drawing.

* *
* *
* *
**
* *
* *
* *

REQUIREMENTS
• One variable could be used for each printed line but you should think of a way to avoid duplicating variables with the same value! The sample used five variables, can you figure out how it was done?
• The program should use the least number of print statements (Hint: use \n for new lines)


pppppppppppplllllllllleeeaaaaaaaaasssssssse

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by quuba
0
public class Picture {

    public static void main(String[] args) {
        String s1 = "pppppppppppplllllllllleeeaaaaaaaaasssssssse";
        String s2 = "pppppppppppp          eeeaaaaaaaaasssssssse";
        String s3 = "            llllllllll ";

        System.out.println(s1 + "\n" + s2 + "\n" + s3 + "\n" + s2 + "\n" + s1);
    }
}

Adopt with your REQUIREMENTS

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.