Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ArithmeticMeanBigger10 {
  4.  
  5. public static void main(String[] args) {
  6. int sum = 0;
  7. int elemNo=0;
  8. int currElem;
  9. Scanner sc = new Scanner(System.in);
  10. while (sc.hasNextInt()) {
  11. currElem=sc.nextInt();
  12. if (currElem > 10) {
  13. sum=sum+currElem;
  14. elemNo=elemNo+1;
  15. }
  16. }
  17. if (elemNo==0) {
  18. System.err.print("No data available\n");
  19. System.exit(1);
  20. }
  21. sc.close();
  22. System.out.print("the sum is "+ sum);
  23. System.exit(0);
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement