Results 1 to 7 of 7
  1. #1
    djtoxicdance is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Smile String array and for loop graphic

    Im in the process of writing a program using a string arrays and for loops so my out put comes out to be a bulls eye using the ("*") to make the shape i have started the code but i got stuck on how to write the string array for the program
    here my code so far
    Java Code:
    public class bullseye {
       	public static void main(String[] args) {
       		String[][] s = new String[30][30];
       		for (int q = 0; q < 15; q = q + 4){
       			for (int w = 0; w < 30; w++){
       				for (int e = 0; e < 30; e++){
       					if ((int)
    
       				}
    the output needs to look some like this
    Java Code:
             *********
          *    ******   *
        *    *           *    *
       *    *             *    *
       *    *     *        *   *
       *    *             *    *
       *     *           *     *
       *      ******        *
         *                     *
           ***********
    the output drawing might not be good i just made it so you get an idea of what im trying to get

  2. #2
    djtoxicdance is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Default

    Sorry the output drawing sucks just imagine a bulls eye like a target thats what i tried making

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Is the program to fill the String array with *s and spaces and then print it or what?
    Can you explain what the program is supposed to do?
    In your posted code, what do the hardcoded int values represent? There is a 15 and a 4 and a 30?
    What do the loop control letters mean? The q and w and e

  4. #4
    djtoxicdance is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Default

    what the program is suppose to do is give me a bulls eye like the one i tried to drawn as an out put using the * as the symbol to make it. the code i posted with with for loops are my values for the bulls eye because when i do shapes i try to imagine it as a grid and build the program of off that idea. but if theres an easier way of doing it then let me know

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    I don't know of any easier way than to build a grid on paper and then row by row output the pattern in your program.

    You seemed to have ignored my questions.
    What do you need an array for if you are using print statements to output the *s?
    What are the values 4, 15 and 30 for?

  6. #6
    djtoxicdance is offline Member
    Join Date
    May 2011
    Posts
    8
    Rep Power
    0

    Default

    i need to build the program using a string array and for loops the numbers in the for loops are used to set distances. 4 is the space between each circle 30 is the hight and length of the array.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Have you drawn your grid and worked out the logic for placing the *s on each row?

    For example the first row could have a single * at the center.
    The next row 2 *s, one before and one after the center.
    Some more rows with changing placements for the 2 *s
    Then start the next circle inside the the outer one.
    Continue to the middle and then create an mirror image of the top for the bottom half.

Similar Threads

  1. String in While loop
    By nebulared in forum New To Java
    Replies: 4
    Last Post: 02-20-2011, 04:19 PM
  2. string loop
    By durdanto in forum New To Java
    Replies: 4
    Last Post: 02-18-2011, 09:06 AM
  3. how to fill and show an array with graphic components?
    By randomjavaguy in forum New To Java
    Replies: 2
    Last Post: 11-08-2010, 09:19 AM
  4. String and while loop
    By Exception in forum Java Applets
    Replies: 5
    Last Post: 09-24-2009, 12:32 PM
  5. Replies: 1
    Last Post: 08-03-2007, 10:52 AM

Posting Permissions

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