1. Member
Join Date
Mar 2012
Posts
2
Rep Power
0

Java Code:
```string toprint = "";
// for each row
for(int row=0; row<n; row++){
toprint = "";
if(row==0){
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){
foreach(0 to n/2) toprint += " ";
toprint = "*";
}
toprint += "\n";
}
print(toprint);```
Last edited by JosAH; 03-28-2012 at 09:33 AM. Reason: added [code] ... [/code] tags

That is absolutely not how this works. What have you tried? Where are you stuck?

3. Member
Join Date
Mar 2012
Posts
2
Rep Power
0

Originally Posted by KevinWorkman
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

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.

#### Posting Permissions

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