Advertisement
justintran17

accumalator

Feb 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. //Justin Tran
  2. //2/9/16
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class HW1
  7. { public static void main(String [] args)
  8. { Scanner input = new Scanner(System.in);
  9. System.out.print("Enter The start integer.");
  10. int a = input.nextInt();
  11. System.out.print("Enter The end integer.");
  12. int b = input.nextInt();
  13. System.out.println("Start integer: " + a);
  14. System.out.println("End integer: " + b);
  15. int c=0;
  16. int d=0;
  17. int t=0;
  18. for (int x =a; x<=b; x++)
  19. { t=x + t; if (t%2 == 0) c++; else d++; }
  20. System.out.println("Total: "+t); System.out.println("Even count: " + c); System.out.println("Odd count: " + d); }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement