Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Nestesailiot {
- public static void main(String[] args) {
- Scanner lukija = new Scanner(System.in);
- int ensimmainen = 0;
- int toinen = 0;
- while (true) {
- System.out.println("Ensimmäinen: " + ensimmainen + "/100");
- System.out.println("Toinen: " + toinen + "/100");
- System.out.print("> ");
- String luettu = lukija.nextLine();
- if (luettu.equals("lopeta")) {
- break;
- }
- if (!(luettu.equals("lopeta"))) {
- String[] osat = luettu.split(" ");
- String komento = osat[0];
- int maara = Integer.valueOf(osat[1]);
- if (komento.equals("lisaa") && maara > 0 && !(ensimmainen + maara > 100)) {
- ensimmainen = ensimmainen + maara;
- continue;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement