0

# How to fix this?(not solved)

I want to make this in the shape of a diamond.. 3/4 successful... But 1/4 does matter😅😅 Problem is on the second space loop... (for loop) https://code.sololearn.com/cafU3MhS2XbE/?ref=app

18th Jan 2019, 2:40 PM
Coding Niffler
+ 3
public class Program { int start; int end; public void calc(){ int sp = 0; int space = 10; //Incrementing loop(first half) for(int i = 10;i>=1;i--){ for(int j = 1;j<=i;j++){ System.out.print("*"); } //Space loop 1 for(int j = 1;j<=sp;j++){ System.out.print(" "); } sp+=2; start = i; //Decrementing loop(second half) for(int j = start;j>=1;j--){ System.out.print("*"); } System.out.println(); } //Incrementing loop:First half(Down) for(int i = 1;i<=10;i++){ for(int j = 1;j<=i;j++){ System.out.print("*"); } //Space loop 2 for(int j = 0;j<space-1;j++){ System.out.print(" "); } space--; //Decrementing loop end = i; for(int j = end;j>=1;j--){ System.out.print("*"); } System.out.println(); } } public static void main(String[] args) { Program obj = new Program(); obj.calc(); } }
18th Jan 2019, 2:44 PM
👑 Prometheus 🇸🇬
+ 3
Changes made: " "->" " j<=space -> j<space-1
18th Jan 2019, 2:44 PM
👑 Prometheus 🇸🇬
+ 2
⏩ Prometheus ⏪ Can you explain? 😅😅 space loop 2
18th Jan 2019, 2:45 PM
Coding Niffler
+ 2
Can't explain much! Haha Okay here is what I went through. To mirror it our I need 2 times the number of spaces. Then after that I just removed 4 spaces from each line as it was misaligned.
18th Jan 2019, 2:46 PM
👑 Prometheus 🇸🇬
0
I don't think it worked...
18th Jan 2019, 2:54 PM
Coding Niffler
0
In line 58: j<10-i; In line 60: System.out.print("two spaces in these quotes");
18th Jan 2019, 3:25 PM
Игорь Яковенко
0
Nope it's not working
20th Jan 2019, 8:13 AM
Coding Niffler
Hot today
Python