Helo there, I am having trouble identifying where I have gone wrong in the below code that I have written for BST (Binary Search Tree) java program: public static void main(String[] args) { Scanner scan = new Scanner(System.in); BST B1 = new BST(); int promt = 1; while (promt >= 1 && promt <= 8) { System.out.println("\nPlease select any of the following options\n"); System.out.println("1. Insert an element into the BST"); System.out.println("2. Search for an element in the BST"); System.out.println("3. Find the maximum element from the BST"); System.out.println("4. Find the minimum element from the BST"); System.out.println("5. Print elements in the BST in preorder"); System.out.println("6. Print elements in the BST in postorder"); System.out.println("7. Print elements in the BST in inorder"); System.out.println("8. Delete an element"); System.out.println("Anything else to exit the program"); promt = scan.nextInt(); switch(promt) { case 1 : System.out.println("Enter any value element to insert in BST"); B1.insert(scan.nextInt()); break; case 2: System.out.println("Enter any element to search in the BST"); B1.search(scan.nextInt()); break; case 3: System.out.println("Find Maximum"); B1.findMax(scan.nextInt()); break; case 4: System.out.println("Find Minimum"); B1.findMin(scan.nextInt()); break; case 5: System.out.println("\n Preorder: "); B1.preorder(); break; case 6: System.out.println("\n Postorder: "); B1.postorder(); break; case 7: System.out.println("\n Inorder: "); B1.inorder(); break; case 8: System.out.println("Delete element"); B1.delete(); case 9: break;    } }   Can someone please help me with this, please? Every time I run the program and enter a value (for example: to insert an element into BST) I keep on getting the same set of options over and over again.  Can someone help, please?   Thanks.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Helo there, I am having trouble identifying where I have gone wrong in the below code that I have written for BST (Binary Search Tree) java program:

public static void main(String[] args)
{

Scanner scan = new Scanner(System.in);

BST B1 = new BST();

int promt = 1;

while (promt >= 1 && promt <= 8)
{
System.out.println("\nPlease select any of the following options\n");
System.out.println("1. Insert an element into the BST");
System.out.println("2. Search for an element in the BST");
System.out.println("3. Find the maximum element from the BST");
System.out.println("4. Find the minimum element from the BST");
System.out.println("5. Print elements in the BST in preorder");
System.out.println("6. Print elements in the BST in postorder");
System.out.println("7. Print elements in the BST in inorder");
System.out.println("8. Delete an element");
System.out.println("Anything else to exit the program");


promt = scan.nextInt();
switch(promt)
{

case 1 :
System.out.println("Enter any value element to insert in BST");
B1.insert(scan.nextInt());
break;

case 2:
System.out.println("Enter any element to search in the BST");
B1.search(scan.nextInt());
break;

case 3:
System.out.println("Find Maximum");
B1.findMax(scan.nextInt());
break;

case 4:
System.out.println("Find Minimum");
B1.findMin(scan.nextInt());
break;

case 5:
System.out.println("\n Preorder: ");
B1.preorder();
break;

case 6:
System.out.println("\n Postorder: ");
B1.postorder();
break;

case 7:
System.out.println("\n Inorder: ");
B1.inorder();
break;

case 8:
System.out.println("Delete element");
B1.delete();

case 9:
break;






   }

}

 

Can someone please help me with this, please? Every time I run the program and enter a value (for example: to insert an element into BST) I keep on getting the same set of options over and over again. 

Can someone help, please?

 

Thanks.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Depth First Search
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education