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. Q.1.5 If the user makes an incorrect product category selection, prompt the user to re-enter a valid product category. Q.1.6 Provide the user with the option to select between the following product warranty options: • 1 – Applies a six-month product warranty. • Any other key applies a two-year warranty. Q.1.7 Once the entire submission has been completed, the user must be informed that the product details have been successfully saved
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
System.out.println("Choose a category: \n1. Desktop Computer \n2. Laptop \n3. Tablet \n4. Printer\n5. Gaming Console");
int c;
c=in.nextInt();
if (c==1){
System.out.println("You have chosen Desktop Computer ");
}
else if (c==2){
System.out.println("You have chosen Laptop");
}
else if (c==3){
System.out.println("You have chosen Tablet");
}
else if (c==4){
System.out.println("You have chosen Printer");
}
else if (c==5){
System.out.println("You have chosen game console");
}
else{
System.out.println("Enter a valid product category");
}
int c2;
System.out.println("Choose warranty:\n1. Applies a six-month product warranty\n2. Any other key applies a two-year warranty");
c2=in.nextInt();
System.out.println("Product details have been successfully saved");
}
}
Comments
Leave a comment