Untitled
unknown
plain_text
2 years ago
1.2 kB
5
Indexable
int duzina = Integer.parseInt(sc.nextLine()); int sirina = Integer.parseInt(sc.nextLine()); int torta = duzina*sirina; int gostuzima=0; while (true) { String stop = sc.nextLine(); if (!stop.equals("STOP")) { gostuzima = Integer.parseInt(stop); torta = torta - gostuzima; if (torta < gostuzima) { int razlika = Math.abs(torta); System.out.printf("No more cake left! You need %d pieces more.", razlika); break; } if (torta == 0) { int razlika = Math.abs(torta); System.out.printf("No more cake left! You need %d pieces more.", razlika); break; } } else { if (torta > gostuzima) { System.out.printf("%d pieces are left.", torta); break; } else { int razlika = Math.abs(torta); System.out.printf("No more cake left! You need %d pieces more.", razlika); break; }
Editor is loading...