Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ex17 {
- public static void main(String []args)
- {
- Scanner in = new Scanner(System.in);
- int num = 0;
- int counter = 0;
- while(num != -1)
- {
- System.out.println("Enter number between 0-9 and enter -1 to finish");
- int newnum = in.nextInt();
- if(num == newnum-1)
- {
- counter++;
- }
- num = newnum;
- }
- System.out.println(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement