JavaProgram i want this output (a-b c-d) but this program gives me (a-b c-d-).
PROGRAM
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;
}
System.out.print("-");
x = x - 1;
}
}
}
Aucun commentaire:
Enregistrer un commentaire