holidaze's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
30 (0.04 per day)
Joined:
27-September 12
Profile Views:
222
Last Active:
User is offline Aug 02 2013 03:42 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   holidaze has not set their status

Posts I've Made

  1. In Topic: Not printing 1st Node entered in stack(toString)

    Posted 23 Feb 2013

    Figured it out.

    In the toString method changed:

    while(node.getNext() != null)
    


    to

    while(node != null)
    



    It was skipping the last entry as it was reading getNext as null.
  2. In Topic: Nested Loops. Choose when to display character based on size of int.

    Posted 18 Jan 2013

    Went to go shower and step away for a little bit. Ended up figuring this out. Thanks for the help again!
  3. In Topic: Nested Loops. Choose when to display character based on size of int.

    Posted 18 Jan 2013

    [quote name='holidaze' date='18 January 2013 - 01:02 AM' timestamp='1358496177' post='1785743']

    View Postmacosxnerd101, on 18 January 2013 - 12:29 AM, said:

    Your conditional doesn't make sense. Why are you checking if col < size? What you really need are two inner loops. The first nested loop prints spaces, and the second prints the hash symbol.

    for(int i = 0; i < rows; i++){
        //use a loop to print rows-i-1 spaces
        //use another loop to print 2i+4
    }
    
    


    Thought, I had it figured out, but then was trying to do the other side of the octagon and got stuck.

    Here is the code I wrote from the advice above.

    for(row = 0; row < size; row++) { 
    	for(space = 0; space < size - row; space++) {
    		System.out.print(" ");
    	}
    	for(hash = 0; hash < size + row * 2; hash++) {
    		System.out.print("#");
    							
    	}
    	System.out.println();
    }
    


    It outputs the above correctly, however, how do I print the inverse of that. Below is what i drafted up based on the other half:

    int size = 4;
    int row;
    int space;
    int hash;
    
    for(row = 0; row < size; row++) { 
    	for(space = -1; space < row; space++) {
    			System.out.print(" ");
    	}
    	for(hash = 0; hash < row + size; hash++) {
    			System.out.print("#");
    	}
    	System.out.println();
    }
    
    


    It outputs the following:

     ####
      #####
       ######
        #######
    


    I believe the adjustments need to be made in the 2nd nested for loop, but not sure how to get it to print correctly. Once again, thanks for the help.
  4. In Topic: Nested Loops. Choose when to display character based on size of int.

    Posted 18 Jan 2013

    View Postmacosxnerd101, on 18 January 2013 - 12:29 AM, said:

    Your conditional doesn't make sense. Why are you checking if col < size? What you really need are two inner loops. The first nested loop prints spaces, and the second prints the hash symbol.

    for(int i = 0; i < rows; i++){
        //use a loop to print rows-i-1 spaces
        //use another loop to print 2i+4
    }
    
    



    This helped a lot. I figured it out. Thanks for the help!
  5. In Topic: Return a String from a method that uses Integers

    Posted 25 Oct 2012

    View PostfromTheSprawl, on 25 October 2012 - 12:42 AM, said:

    Why not use a for loop? Your instructor is basically saying you do two loops, forward and reverse motions. Sample:

    int n = //input
    //forward
    for(int x = 0; x < n; x++){
    //build the string to be returned here
    }
    
    for(int x = n; x > ; x--){
    //build the string to be returned here
    }
    
    

    That's it. Notice how the arguments for the two for loops are reversed. So if the output on the above for 5 is 0,1,2,3,4,5, you'll get the reverse with the reversed for loop. ^^


    Yah, I understood the formula part and how to achieve the countdown/countup, but the part I don't understand is how to return a string when I am working with Integers. Sorry for the confusing post before.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

holidaze hasn't added any friends yet.

Comments

holidaze has no profile comments yet. Why not say hello?