he user must have the option to delete a product that has been saved. The user must first enter the product code to be deleted. Next, the user must confirm whether they want to delete the product. Q.1.10 The user must also have the ability to update specific details of the product. For example, the user must first enter the product code and then confirm whether to update the following product details: • Update the product warranty. • Update the product price. • Update the product stock level
import java.util.Scanner;
public class Main
{
public static void main(String[] args){
int code,option,option2;
System.out.print("Choose an option \n1.Delete a product\n2.Update details of a product: ");
Scanner input=new Scanner(System.in);
option=input.nextInt();
if(option==1)
{
//Scanner input=new Scanner(System.in);
System.out.print("Enter the product code: ");
code=input.nextInt();
System.out.print("Are you sure you want to delete the product?\n1.Yes\n2.No\n");
option=input.nextInt();
if(option==1){
System.out.print("The product deleted successfully");
}
else{
System.out.print("The product not deleted.");
}
}
else if(option==2)
{int option3;
System.out.print("Enter the product code: ");
code=input.nextInt();
System.out.print("Choose an update to perform\n1.Update the product warranty\n2.Update the product price\n3.Update the product stock \nlevel ");
option3=input.nextInt();
if(option3==1)
{
System.out.print("Are you sure you want to update the product warranty?\n1.Yes\n2.No\n");
option=input.nextInt();
if(option==1){
System.out.print("Waranty updated successfully");
}
else{
System.out.print("Warranty not updated.");
}
}
else if(option3==2)
{
System.out.print("Are you sure you want to update the product price?\n1.Yes\n2.No\n");
option=input.nextInt();
if(option==1){
System.out.print("Price updated successfully");
}
else{
System.out.print("Price not updated.");
}
}
else if(option3==3)
{
System.out.print("Are you sure you want to update the product stock level?1.Yes\n2.No\n");
option=input.nextInt();
if(option==1){
System.out.print("Product stock level updated successfully");
}
else{
System.out.print("Product stock level not updated.");
}
}
else{
System.out.print("Invalid option!");
}
}
else{
System.out.print("Invalid option!");
}
}}
Comments
Leave a comment