Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1.  
  2. public class sample {
  3.  
  4. public static void main(String[] args){
  5.  
  6. System.out.println("Enter a set of integers to add to the list, and enter 0 when done to begin program: ");
  7. int number = IO.readInt();
  8. int counte = 0;
  9. int counto = 0;
  10. while(number != 0){
  11. if(number ==0){
  12. break;
  13. }
  14.  
  15.  
  16.  
  17.  
  18. if(number % 2 == 0){
  19. counte = counte + 1;
  20. number = IO.readInt();
  21. }else{
  22. counto = counto + 1;
  23. number = IO.readInt();
  24. }
  25. }
  26. System.out.println("The total number of even numbers is: " + counte);
  27. System.out.println("The total number of odd numbers is: " + counto);
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement