Welcome to Dream.In.Code
Become a Java Expert!

Join 149,602 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,897 people online right now. Registration is fast and FREE... Join Now!




need urgent help

 
Reply to this topicStart new topic

need urgent help

pramen
18 Aug, 2007 - 08:55 PM
Post #1

New D.I.C Head
*

Joined: 18 Aug, 2007
Posts: 1


My Contributions
i am a beginer and i have to make following shapes for my school project. somebody please help me:
1) *******
*****
***
*
2)

1234567
123456
12345
1234
123
12
1
12
123
1234
12345
123456
1234567

please help me

thanks in advance

User is offlineProfile CardPM
+Quote Post

alpha02
RE: Need Urgent Help
18 Aug, 2007 - 09:38 PM
Post #2

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
The first one:

CODE
for (int i=7; i>0; i-=2){
    String line = "";
    for (int j=0; j<i; j++){
        line = line.concat("*");
    }
    System.out.println(line);
}


The second one:

CODE
for (int i=7; i>0; i--){
    String line = "";
    for (int j=0; j<i; j++){
        line = line.concat(j+1);
    }
    System.out.println(line);
for (int i=2; i<=8; i++){
    String line = "";
    for (int j=0; j<i; j++){
        line = line.concat(j+1);
    }
    System.out.println(line);
}


I wrote these codes on the fly and I haven't tested them yet.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month