Answer to Question #237600 in Java | JSP | JSF for Eully

Question #237600
Special consideration needs to be made for the selection of the product category. Allow
the user to make a selection between the following categories:
• Desktop Computer.
• Laptop.
• Tablet.
• Printer.
• Gaming Console.
1
Expert's answer
2021-09-15T11:41:50-0400


import java.util.Scanner;




public class Main {


	


	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int ch = -1;
		while (ch != 6) {
			System.out.println("1. Desktop Computer.");
			System.out.println("2. Laptop.");
			System.out.println("3. Tablet.");
			System.out.println("4. Printer.");
			System.out.println("5. Gaming Console.");
			System.out.println("6. Exit.");
			System.out.print("Select the product category: ");
			ch = in.nextInt();
			in.nextLine();
			if (ch == 1) {
				System.out.println("You have selected Desktop Computer.");	
			} else if (ch == 2) {
				System.out.println("You have selected Laptop.");
			} else if (ch == 3) {
				System.out.println("You have selected Tablet.");
			} else if (ch == 4) {
				System.out.println("You have selected Printer.");
			} else if (ch == 5) {
				System.out.println("You have selected Gaming Console.");
			} else if (ch == 6) {
			
			} else {
				System.out.println("Wrong selection.");
			}
		}
		in.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS