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

Recommended Answers

All 2 Replies

good luck finding someone to help you do your assignment :)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.