Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package kullpanustega;
  2.  
  3. import tunnifor.TextIO;
  4.  
  5. public class Kullpanustega {
  6.  
  7. public static int sisestaRaha() {
  8. TextIO.putln("Sisesta raha summa");
  9. int raha = TextIO.getlnInt();
  10. return (raha);
  11. }
  12.  
  13. public static int viskaMynti() {
  14. int kull = (int) (Math.random() * 2);
  15. return kull;
  16. }
  17.  
  18. public static int kullvoiKiri() {
  19. TextIO.putln("Kull (0) või Kiri (1)");
  20. int kull = TextIO.getlnInt();
  21.  
  22. return kull;
  23. }
  24.  
  25. public static int kysiPanus() {
  26.  
  27. while (true) {
  28. int raha = sisestaRaha();
  29. TextIO.putln("Sisesta panus");
  30. int panus = TextIO.getlnInt();
  31. if (panus > raha)
  32. TextIO.putln("Üritad panustada rohkem kui raha on");
  33. else if (!(panus < 1 && panus > 100))
  34. ;
  35. else
  36. raha -= panus;
  37. return panus;
  38. }
  39. }
  40.  
  41. public static void main(String args[]) {
  42. int raha = sisestaRaha();
  43. int panus = kysiPanus();
  44. int kull = viskaMynti();
  45.  
  46. // while (raha < 10000)
  47.  
  48. TextIO.putln("Sul on taskus " + raha + " eurot.");
  49.  
  50. if (kull == 0) {
  51. TextIO.putln("Võitsid raha");
  52. raha += panus * 2;
  53. } else {
  54. TextIO.putln("Tuli kiri, kaotasid");
  55. raha -= panus * 2;
  56. }
  57.  
  58. TextIO.putln("Papp otsas, pidu läbi");
  59. raha = raha - panus;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement