Page 1 of 1

Please show the following codes below using Netbeans. I want to see the codes in Netbeans in each line and runs succesfu

Posted: Thu Jun 02, 2022 8:38 am
by answerhappygod
Please show the following codes below using Netbeans. I want to see the codes in Netbeans in each line and runs succesful.Class name is "Main".

/Main method
public static void main(String[] args) throws ParseException {

Scanner sc = new Scanner(System.in); //Scanner class object to take input

LinkedList list = new LinkedList(); //main list object

while(true) {

//displaying the menu
System.out.println();
System.out.println("Enter 1 to insert any product");
System.out.println("Enter 2 to update the cost of any product");
System.out.println("Enter 3 to update the quantity of any product");
System.out.println("Enter 4 to search any product.");
System.out.println("Enter 5 to get the must sell products");
System.out.println("Enter 6 to display all the products");
System.out.println("Enter 7 to quit");
System.out.println();

int choice = sc.nextInt();

if(choice == 1) {
System.out.println();
System.out.print("Enter the Product code: ");
int code = sc.nextInt();

System.out.print("Enter the Product Name: ");sc.nextLine();
String name = sc.nextLine();

System.out.print("Enter the Product Cost: ");
double cost = sc.nextDouble();

System.out.print("Enter the Product Quantity: ");
double quantity = sc.nextDouble();

System.out.print("Enter the SellBy date..Date should be in yyyy-MM-dd format:");sc.nextLine();
String date = sc.nextLine();

Date sellBy = new SimpleDateFormat("yyyy-MM-dd").parse(date);

list.insert(code, name, cost, quantity, sellBy);

System.out.println("Product added");
}
else if(choice == 2) {
System.out.println();
System.out.print("Enter the Product code: ");
int code = sc.nextInt();

System.out.print("Enter the Product Cost: ");
double cost = sc.nextDouble();

list.update_cost(code, cost);

}
else if(choice == 3) {

System.out.println();
System.out.print("Enter the Product code: ");
int code = sc.nextInt();

System.out.print("Enter the Product Quantity: ");
double quantity = sc.nextDouble();

list.update_quantity(code, quantity);

}
else if(choice == 4) {
System.out.println();
System.out.print("Enter the Product code: ");
int code = sc.nextInt();
list.search(code);
}
else if(choice == 5) {
list.must_sell();
}
else if(choice == 6) {
list.display();
}
else if(choice == 7) {
break;
}
else {
System.out.println("Incorrect choice entered. Please Enter again");
}

}

sc.close(); //closing the Scanner input

}

}