Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. System.out.print("Введите минимум: ");
  9. int min = scanner.nextInt();
  10.  
  11. System.out.print("Введите максмум: ");
  12. int max = scanner.nextInt();
  13.  
  14. main: while(true) {
  15. int avr = (int) Math.ceil((max - min) / 2f + min);
  16.  
  17. System.out.append("Число больше или равно ");
  18. System.out.append(Integer.toString(avr));
  19. System.out.print(" (+/-/=): ");
  20.  
  21. String condition = scanner.next();
  22.  
  23. switch(condition) {
  24. case "+":
  25. min = avr;
  26. break;
  27. case "-":
  28. max = avr;
  29. break;
  30. case "=":
  31. System.out.append("Загаданное число ");
  32. System.out.println(avr);
  33. break main;
  34. }
  35. }
  36.  
  37. scanner.close();
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement