-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLista_03_Ex10.java
More file actions
44 lines (34 loc) · 974 Bytes
/
Lista_03_Ex10.java
File metadata and controls
44 lines (34 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Random;
import java.util.Scanner;
public class Lista_03_Ex10
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
Random rnd = new Random();
int inicial = 1024, fim = 0;
for (int i = 0; i <= 9; i++)
{
int x = rnd.nextInt((inicial - fim) + 1) + fim;
System.out.println("Seu número é maior ou menor que: " + x );
System.out.println("> para maior, < para menor, = para igual");
char aux = sc.next().charAt(0);
if (aux == '>') {
if (fim < x)
{
fim = x;
}
}
if (aux == '<') {
if (inicial > x)
{
inicial = x;
}
}
if(aux == '=') {
System.out.println("Acertou!!");
}
}
System.out.println("Fim");
}
}