Results 1 to 2 of 2

Thread: Need help to write this program in java?

  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Need help to write this program in java?

    -hi
    -I recently started learning java language. Yesterday our sir has given us assignment in which there is a program like write java program to show using star and "-" is space
    - ----- *
    - ----**
    - ---***
    - --****
    - *****
    - and
    ---------*
    --------***
    -------*****
    ------*******
    -----*********
    ------*******
    -------*****
    --------***
    ---------*
    Last edited by frkadeel; 01-12-2010 at 12:17 AM.

  2. #2
    Join Date
    Dec 2007
    Posts
    2,297

    Re: Need help to write this program in java?

    I will write a java program for CROSS STARS pattern using NESTED LOOP, which you can refer below:

    for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
    if ( i == j || ( i+j == 10 )) {
    System.out.printf("*");
    } else {
    System.out.printf("");
    }
    }
    System.out.println();
    }

    replace 10 with the user input for number of stars

Similar Threads

  1. How to write program to generate a pascal triangle in java?
    By Aandaleeb in forum Software Development
    Replies: 7
    Last Post: 11-09-2011, 12:37 PM
  2. How to write java program to print pyramid of stars?
    By Nadiaa in forum Software Development
    Replies: 6
    Last Post: 19-08-2011, 05:03 PM
  3. How to write string data to file using java program?
    By Linoo in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 08:26 PM
  4. How to write java program to find factorial of number?
    By Balamohan in forum Software Development
    Replies: 5
    Last Post: 28-11-2009, 09:14 PM
  5. how to write program on palindrome in java?
    By Linoo in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •