Question
Write Java application to do the following: a. Declare a BSTNotebook object named nbList. b. Insert THREE (3) Notebook objects into the binary search tree.
Write Java application to do the following:
a. Declare a BSTNotebook object named nbList.
b. Insert THREE (3) Notebook objects into the binary search tree.
c. Display the details of all notebooks.
d. Count and display the number of HP notebooks with price greater than
RM5,000.
e. Calculate and display the total price of all notebooks stored in the binary search
tree.
f. Display the most expensive notebook.
g. Search and display the details of a notebook based on the serial number entered
by the user.
public class Notebook
{
private String serialNo;
private String brand; // HP, Acer, Lenovo, etc.
private double price;
public String getSN() {...}
public String getBrand() {...}
public double getPrice(){...}
// definition of other methods
}
public class TreeNode
{
TreeNode left;
Notebook data;
TreeNode right;
}
public class BSTNotebook
{
TreeNode root;
public void display(){...}
public int count(){...}
public double totalPrice(){...}
public double maxPrice(){...}
public String search(String){...}
// definition of other methods
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started