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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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

}

}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply