Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. port java.util.Scanner;
  2. public class Assignment333
  3.  
  4. {
  5. public static void main (String[] args)
  6. {
  7. Scanner input = new Scanner (System.in);
  8. int productCounter1 = 0;
  9. int productCounter2 = 0;
  10.  
  11. System.out.print("Enter product number in the range 1-5 or enter the value -1 to terminate: ");
  12. int products = input.nextInt();
  13. while (products != -1)
  14.  
  15. {
  16. switch (products)
  17. {
  18. case 1:
  19. ++productCounter1;
  20. break;
  21. case 2:
  22. ++productCounter2;
  23. break;
  24. }
  25. System.out.print("Enter product number in the range 1-5 or enter the value -1 to terminate: ");
  26. products = input.nextInt();
  27. }
  28.  
  29. System.out.printf("Product 1:%d%nProduct 2:%d%n", productCounter1, productCounter2);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement