Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public class Nestesailiot {
  2.  
  3.  
  4. public static void main(String[] args) {
  5. Scanner lukija = new Scanner(System.in);
  6.  
  7. int ensimmainen = 0;
  8. int toinen = 0;
  9.  
  10.  
  11. while (true) {
  12. System.out.println("Ensimmäinen: " + ensimmainen + "/100");
  13. System.out.println("Toinen: " + toinen + "/100");
  14.  
  15.  
  16. System.out.print("> ");
  17.  
  18. String luettu = lukija.nextLine();
  19.  
  20.  
  21.  
  22. if (luettu.equals("lopeta")) {
  23. break;
  24. }
  25.  
  26. if (!(luettu.equals("lopeta"))) {
  27. String[] osat = luettu.split(" ");
  28. String komento = osat[0];
  29. int maara = Integer.valueOf(osat[1]);
  30.  
  31. if (komento.equals("lisaa") && maara > 0 && !(ensimmainen + maara > 100)) {
  32. ensimmainen = ensimmainen + maara;
  33. continue;
  34. }
  35.  
  36.  
  37.  
  38.  
  39. }
  40. }
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement