Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. import javax.swing.JOptionPane;
  3.  
  4. public class H4_OEF1
  5. {
  6.  
  7. public static void main (String args[])
  8. {
  9.  
  10. String getalS;
  11. int getal, vorige, teller=0;
  12.  
  13.  
  14. //inlezen eerste getal
  15.  
  16. getalS = JOptionPane.showInputDialog("Geef een getal, afgesloten door -2000");
  17. getal = Integer.parseInt(getalS);
  18.  
  19.  
  20.  
  21. while(getal != -2000 )
  22. {
  23.  
  24. //vorige aanpassen
  25.  
  26. vorige=getal;
  27.  
  28. //inlezen volgende getal
  29.  
  30. getalS = JOptionPane.showInputDialog("Geef een getal, afgesloten door -2000");
  31. getal = Integer.parseInt(getalS);
  32.  
  33. //vorige>getal => teller++
  34.  
  35. if(vorige>getal)
  36. teller++;
  37.  
  38.  
  39.  
  40. } //einde while
  41.  
  42. String resul;
  43.  
  44. resul=String.format("Het aantal keer = %d", teller);
  45.  
  46. JOptionPane.showMessageDialog(null, resul);
  47.  
  48.  
  49. }
  50. }
Add Comment
Please, Sign In to add comment