Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package teste;
- import java.util.Scanner;
- public class Ex6 {
- public Ex6() {
- int total = 0;
- System.out.println("Vamos Jogar um jogo com dois jogadores.");
- System.out.println("|-------------------------------------|");
- System.out.println("| |");
- System.out.println("| |");
- System.out.println("| Tente adivinhar o numero! |");
- System.out.println("| De 1 a 10 |");
- System.out.println("| |");
- System.out.println("| |");
- System.out.println("|-------------------------------------|");
- int escolha = new java.util.Random().nextInt(10);
- //System.out.println(escolha);
- for (int i = 1 ;; i++) {
- System.out.println("Digite um numero de 1 a 10!");
- int num = new Scanner(System.in).nextInt();
- for (int j = 0; j < 10 ; j++) {
- System.out.println(" ");
- }
- if (i < 3) {
- if (num != escolha) {
- if (num > escolha) {
- System.out.println("Numero e mais baixo");
- }
- if (num < escolha) {
- System.out.println("Numero e mais alto");
- }
- System.out.println(i + " Tentativa");
- continue;
- }
- if (num == escolha) {
- System.out.println("Acertou! Tentou " + i + " vezes.");
- }
- }
- if (i == 3) {
- total = escolha - num;
- System.out.println("Esgotou as 3 tentativas o numero era " + i);
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement