Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Scanner Entrada = new Scanner(System.in);
  2.  
  3. comenzarJuego = Entrada.nextInt();
  4.  
  5. while (comenzarJuego == 1)
  6. {
  7. System.out.println("Ha perdido o ganado?n");
  8. System.out.println("Entre 1 por si gano el juegon");
  9. System.out.println("Emntre 2 poor si perdio el juegon");
  10.  
  11. partida = Entrada.nextInt();
  12.  
  13. if(partida == 1 )
  14. {
  15. ganado++;
  16. }
  17. else if (partida == 2 )
  18. {
  19.  
  20. perdido++;
  21. }
  22.  
  23.  
  24. System.out.println("Quiere continuar a jugar? ente 1 para continuar y 2 para salir del programa.n");
  25.  
  26. comenzarJuego = Entrada.nextInt();
  27.  
  28. }
  29. System.out.println("Numero de partidas perdidas: " + perdido);
  30. System.out.println("numero de partidas ganadas : " + ganado);
  31. System.out.println("Tiempo total del juego :" );
  32.  
  33. import java.lang.*;
  34.  
  35. public class Demo {
  36.  
  37. public static void main(String[] args) {
  38.  
  39. // rdevuelve el tiempo en milliseconds
  40.  
  41. System.out.print("tiempo en milliseconds = ");
  42. System.out.println(System.currentTimeMillis());
  43.  
  44. }
  45. }
  46.  
  47. final long start = System.nanoTime();
  48. final long end = System.nanoTime();
  49.  
  50. System.out.println("Tiempo: " + ((end - start) / 1000000) + "ms);
  51. System.out.println("Tiempo: " + ((end - start) / 1000000000.0)) + "seg");
  52.  
  53. long start = System.currentTimeMillis();
  54. long end = System.currentTimeMillis();
  55.  
  56. System.out.println("Tiempo: " + ((end - start) / 1000)) + "seg");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement