Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package testgargamele;
  7.  
  8. import java.time.temporal.TemporalAdjusters;
  9. import java.util.Scanner;
  10.  
  11. /**
  12. *
  13. * @author uczen
  14. */
  15. public class TestGargamele {
  16.  
  17. /**
  18. * @param args the command line arguments
  19. */
  20. public static void main(String[] args) throws InterruptedException {
  21. System.out.println("Ile razy");
  22. Scanner skaner=new Scanner(System.in);
  23. int ilosc = skaner.nextInt();
  24. System.out.println("Ustal stopień zaawansowania (1-zielona żaba,2-różowy wyjadacz,3-czarny wymiatacz");
  25. int zaawansowanie=skaner.nextInt();
  26. int zakres;
  27.  
  28. switch(zaawansowanie)
  29. {
  30. case 1: zakres=10; break;
  31. case 2: zakres=20; break;
  32. case 3: zakres=100; break;
  33. default: zakres = 30;
  34. }
  35. int dobre=0;
  36. for(int i=0; i<ilosc; i++)
  37. {
  38. int a=(int)(Math.random()*zakres);
  39. int b=(int)(Math.random()*zakres);
  40.  
  41. System.out.println(a+"*"+b+"=");
  42. int odpowiedz= skaner.nextInt();
  43. if(odpowiedz ==a*b)
  44. {
  45. System.out.println("dobrze");
  46. dobre=dobre+1;
  47. Thread.sleep(1000);
  48. }
  49. else {
  50. System.out.println("Źle");
  51. System.out.println("prawdiłowa odpowiedź to:"+(a*b));
  52. Thread.sleep(3000);
  53. }
  54. }
  55. System.out.println("statystyki:\n ilśc dobrch odpowiedzi:"+dobre+"\n z:"+ilosc+"\n wynik dobrych odpowiedi w %:");
  56. double procent=(dobre*100.0)/ilosc);
  57. System.out.format("%.2f%%",procent);
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement