Advertisement
AmbrosioPT

teste

Mar 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package teste;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Ex6 {
  6.  
  7. public Ex6() {
  8.  
  9. int total = 0;
  10.  
  11. System.out.println("Vamos Jogar um jogo com dois jogadores.");
  12. System.out.println("|-------------------------------------|");
  13. System.out.println("| |");
  14. System.out.println("| |");
  15. System.out.println("| Tente adivinhar o numero! |");
  16. System.out.println("| De 1 a 10 |");
  17. System.out.println("| |");
  18. System.out.println("| |");
  19. System.out.println("|-------------------------------------|");
  20.  
  21. int escolha = new java.util.Random().nextInt(10);
  22. //System.out.println(escolha);
  23.  
  24. for (int i = 1 ;; i++) {
  25.  
  26. System.out.println("Digite um numero de 1 a 10!");
  27. int num = new Scanner(System.in).nextInt();
  28.  
  29. for (int j = 0; j < 10 ; j++) {
  30.  
  31. System.out.println(" ");
  32.  
  33. }
  34.  
  35. if (i < 3) {
  36.  
  37. if (num != escolha) {
  38.  
  39. if (num > escolha) {
  40.  
  41. System.out.println("Numero e mais baixo");
  42.  
  43. }
  44.  
  45. if (num < escolha) {
  46.  
  47. System.out.println("Numero e mais alto");
  48.  
  49. }
  50.  
  51. System.out.println(i + " Tentativa");
  52. continue;
  53.  
  54. }
  55.  
  56. if (num == escolha) {
  57.  
  58. System.out.println("Acertou! Tentou " + i + " vezes.");
  59.  
  60. }
  61.  
  62. }
  63.  
  64. if (i == 3) {
  65.  
  66. total = escolha - num;
  67.  
  68. System.out.println("Esgotou as 3 tentativas o numero era " + i);
  69.  
  70. return;
  71.  
  72. }
  73.  
  74. }
  75.  
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement