Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- port java.util.Scanner;
- public class Assignment333
- {
- public static void main (String[] args)
- {
- Scanner input = new Scanner (System.in);
- int productCounter1 = 0;
- int productCounter2 = 0;
- System.out.print("Enter product number in the range 1-5 or enter the value -1 to terminate: ");
- int products = input.nextInt();
- while (products != -1)
- {
- switch (products)
- {
- case 1:
- ++productCounter1;
- break;
- case 2:
- ++productCounter2;
- break;
- }
- System.out.print("Enter product number in the range 1-5 or enter the value -1 to terminate: ");
- products = input.nextInt();
- }
- System.out.printf("Product 1:%d%nProduct 2:%d%n", productCounter1, productCounter2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement