Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class H4_OEF1
- {
- public static void main (String args[])
- {
- String getalS;
- int getal, vorige, teller=0;
- //inlezen eerste getal
- getalS = JOptionPane.showInputDialog("Geef een getal, afgesloten door -2000");
- getal = Integer.parseInt(getalS);
- while(getal != -2000 )
- {
- //vorige aanpassen
- vorige=getal;
- //inlezen volgende getal
- getalS = JOptionPane.showInputDialog("Geef een getal, afgesloten door -2000");
- getal = Integer.parseInt(getalS);
- //vorige>getal => teller++
- if(vorige>getal)
- teller++;
- } //einde while
- String resul;
- resul=String.format("Het aantal keer = %d", teller);
- JOptionPane.showMessageDialog(null, resul);
- }
- }
Add Comment
Please, Sign In to add comment