Guest User

Untitled

a guest
May 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package week3;
  2.  
  3. /**
  4. *
  5. * @author Ilie
  6. */
  7. import javax.swing.JOptionPane;
  8.  
  9. public class Opdracht3 {
  10.  
  11. public Opdracht3() {
  12.  
  13. int hoog = 100001;
  14. int laag = 1;
  15.  
  16.  
  17. do {
  18. int gok = ((hoog - laag) / 2) + laag;
  19. int raad = JOptionPane.showOptionDialog(null // Center in window.
  20. , "Is dit het juiste getal? " + gok // Message
  21. , "Raad maar Raak" // Title in titlebar
  22. , JOptionPane.YES_NO_OPTION // Option type
  23. , JOptionPane.PLAIN_MESSAGE // messageType
  24. , null // Icon (none)
  25. , new Object[]{" Hoger", " Lager", " Juist!"} // Button text as above.
  26. , "Default" // Default button's label );
  27. );
  28.  
  29. System.out.println(" raad= " + raad);
  30. if (raad == 0) {
  31. laag = gok;
  32. }
  33. if (raad == 1) {
  34. hoog = gok;
  35. }
  36. if (raad == 2) {
  37. break;
  38. }
  39. }while (false);
  40. }
  41.  
  42.  
  43.  
  44.  
  45. public static void main(String[] args) {
  46. new Opdracht3();
  47.  
  48. }
  49. }
Add Comment
Please, Sign In to add comment