Results 1 to 4 of 4
  1. #1
    alloka is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default please help convert this pseudo code to java

    Java Code:
    string toprint = "";
    // for each row
    for(int row=0; row<n; row++){        
            toprint = "";
            if(row==0){
                    // leading spaces = n/2
                    foreach(0 to n/2) toprint += " ";
                    toprint += "*";
            }
            else if((row>0)&&(row<n/2)){
                    // leading spaces = n/2 - row number
                    foreach((n/2)-row) toprint += " ";
                    
                    // 3 stars in each row>0 && row < n/2
                    for(int i=0; i<3; i++){
                            toprint +="*";
                            string spaces = "";
                            
                            // spaces between stars = row number -1
                            foreach(0 to row-1) spaces += " ";
                            toprint += spaces;
                    }
            }
            else if(row==n/2){
                    foreach(0 to n){
                            toprint += "*";
                    }
            }
            else if((row>n/2)&&(row<n-1)){
                    foreach(0 to row-(n/2)) toprint += " ";
                    
                    // 3 stars in each row>n/2 && row < n-1
                    for(int i=0; i<3; i++){
                            toprint +="*";
                            string spaces = "";
                            
                            // spaces between stars = n - row number-2
                            foreach(0 to n-row-2) spaces += " ";
                            toprint += spaces;
                    }
            }
            else if(row==n-1){
                    // leading spaces = n/2
                    foreach(0 to n/2) toprint += " ";
                    toprint = "*";
            }
            toprint += "\n";
    }
    print(toprint);
    Last edited by JosAH; 03-28-2012 at 08:33 AM. Reason: added [code] ... [/code] tags

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: please help convert this pseudo code to java

    That is absolutely not how this works. What have you tried? Where are you stuck?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    alloka is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: please help convert this pseudo code to java

    Quote Originally Posted by KevinWorkman View Post
    That is absolutely not how this works. What have you tried? Where are you stuck?
    I've tried to do it but it didn't give me the shape it's so hard problem i tried so many answers and it just won't come out here it is Assignment01_9553.pdf

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: please help convert this pseudo code to java

    Few folks are going to click on a link. If you need our help, post your code here in the forum along with any error messages or misbehaviors.

Similar Threads

  1. Help me re-write pseudo code?
    By csisdifficult in forum New To Java
    Replies: 15
    Last Post: 04-21-2011, 06:30 AM
  2. Starting Pseudo-Code For My Asignment?
    By EpyonCustom in forum New To Java
    Replies: 26
    Last Post: 04-07-2011, 11:07 AM
  3. pseudo code
    By jamiem in forum New To Java
    Replies: 4
    Last Post: 12-20-2010, 05:25 PM
  4. Convert java code to midlet code
    By coldvoice05 in forum New To Java
    Replies: 1
    Last Post: 08-12-2009, 11:14 AM
  5. Convert java code to midlet code
    By coldvoice05 in forum Advanced Java
    Replies: 1
    Last Post: 08-09-2009, 01:21 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
  •