0

java program

I want (a-b c-d) but this gives me (a-b c-d-) public static void main(String[] args) { int x = 3; while (x > 0) { if (x > 2) { System.out.print("a"); } if (x == 2) { System.out.print("b c"); } if (x == 1) { System.out.print("d"); x = x - 1; } else System.out.print("-"); x = x - 1; } }

4th Sep 2021, 7:46 PM
Minhaj Haider
Minhaj Haider - avatar
2 Réponses
4th Sep 2021, 8:01 PM
Coding Cat
Coding Cat - avatar
+ 1
Coding Cat [Mouse searching] ooh yeah.. actually I was worried from morning because of else and now I'm seeing else actually I was written without else ...in my computer...idk how else is coming here... anyway this program is running fine .. thank you
4th Sep 2021, 8:08 PM
Minhaj Haider
Minhaj Haider - avatar