-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
58 lines (40 loc) · 1.19 KB
/
Main.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.awt.*;
import java.util.Scanner;
import java.util.Random; // here
public class Main {
public static void main(String[] args)
{
Dicotomie(args);
}
public static void Dicotomie(String[] args){
Random r = new Random();
int Low = 1;
int High = 100;
int Result = r.nextInt(High-Low) + Low;
System.out.println("enter number between 1 and 100");
Scanner n = new Scanner(System.in);
int Key_num =n.nextInt();
while(Key_num !=Result)
{
if (Key_num < Result)
{
System.out.println("Enter upper number ");
n.next();
Key_num = n.nextInt();
}
else if (Key_num > Result)
{
System.out.println("Enter lower number");
n.next();
Key_num = n.nextInt();}
}
System.out.println("Lucky you !! You found it ;)");}
public static void Reverse_echo (String[] args) {
int l = args.length;
System.out.print(args[l-1]);
for (int i = l - 2; i >= 0; --i) {
System.out.print(" " + args[i]);
}
System.out.println("");
}
}