Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package testgargamele;
- import java.time.temporal.TemporalAdjusters;
- import java.util.Scanner;
- /**
- *
- * @author uczen
- */
- public class TestGargamele {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws InterruptedException {
- System.out.println("Ile razy");
- Scanner skaner=new Scanner(System.in);
- int ilosc = skaner.nextInt();
- System.out.println("Ustal stopień zaawansowania (1-zielona żaba,2-różowy wyjadacz,3-czarny wymiatacz");
- int zaawansowanie=skaner.nextInt();
- int zakres;
- switch(zaawansowanie)
- {
- case 1: zakres=10; break;
- case 2: zakres=20; break;
- case 3: zakres=100; break;
- default: zakres = 30;
- }
- int dobre=0;
- for(int i=0; i<ilosc; i++)
- {
- int a=(int)(Math.random()*zakres);
- int b=(int)(Math.random()*zakres);
- System.out.println(a+"*"+b+"=");
- int odpowiedz= skaner.nextInt();
- if(odpowiedz ==a*b)
- {
- System.out.println("dobrze");
- dobre=dobre+1;
- Thread.sleep(1000);
- }
- else {
- System.out.println("Źle");
- System.out.println("prawdiłowa odpowiedź to:"+(a*b));
- Thread.sleep(3000);
- }
- }
- System.out.println("statystyki:\n ilśc dobrch odpowiedzi:"+dobre+"\n z:"+ilosc+"\n wynik dobrych odpowiedi w %:");
- double procent=(dobre*100.0)/ilosc);
- System.out.format("%.2f%%",procent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement