fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main(String[] args) {
  8. int n;
  9. Scanner input = new Scanner(System.in);
  10. n = input.nextInt();
  11. input.nextLine();
  12. Election obj = new Election(n);
  13. obj.getVotes();
  14. }
  15. }
  16.  
  17. class Election {
  18. int n,v1,v2,v3,v4,v5,d;
  19. public Election(int n) {
  20. this.n = n;
  21. v1=v2=v3=v4=v5=d=0;
  22. }
  23. public void getVotes() {
  24. Scanner sc = new Scanner(System.in);
  25. for(int i = 0 ; i < 1 ; i++) {
  26. int var = sc.nextInt();
  27. switch(var) {
  28. case 1: ++v1; break;
  29. case 2: ++v2; break;
  30. case 3: ++v3; break;
  31. case 4: ++v4; break;
  32. case 5: ++v5; break;
  33. default: ++d; break;
  34. }
  35. }
  36. }
  37. }
Runtime error #stdin #stdout #stderr 0.07s 2184192KB
stdin
5
1 2 3 4 5
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.util.Scanner.throwFor(Scanner.java:862)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextInt(Scanner.java:2117)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at Election.getVotes(Main.java:26)
	at Ideone.main(Main.java:13)