1.
Electronics Manufacturer -Modified
ANY MEANS OF ISTENDED PLAGIARISM WHILE ATTEMPTING THIS QUESTION IS LIABLE TO
HIGHEST POSSIBLE STRICT HR ACTIONS AS IT IS VIOLATION IF INTEGRITY. HENCE, REFRAIN
FROM ANY SUCH MEANS AND ATTEMPT THIS QUESTION AS PER YOUR EXPERTISE ONLY.
You are tasked with designing a system to manage manufacturers and their products.
The system involves the following:
Class Manufacturer:
Attributes:
- manufacturerld (int)
- manufacturer Name (String)
- noOfProducts (int)
- products (List of Strings): A list of product names.
prices (List of Integers): A list of prices corresponding to the products.
Create getters, setters and constructor for the above Manufacturer class.
The two non-static methods described below, should be created in a
ManufacturerService Class:
Task 1: Find the Average Price of Products by Manufacturer
Create a non-static method that calculates and returns the average price of all
products for a s. ified manufacturer.
- The method should accept an integer parameter, 'manufacturerld'.
- It should fetch all products associated with the given 'manufacturerld' and
calculate the average price.
- If there are no products associated with the given 'manufacturerld', or if the
manufacturer does not exist, the method should print "Manufacturer Not Found" and
return 'null' (or handle as needed).
Task 2: Find Manufacturers by Product Name
Create a non-static method that retrieves a list of manufacturers who produce a
specific product.
- The method should accept a string parameter, 'productName'.
- It should search for all manufacturers that produce the product with the given
'productName' and return a list of manufacturer names.
- If no manufacturers are found for the given 'productName', the method should
throw a custom exception called 'ProductNotFoundException', which includes the
message "Product Not Found".
Note:
-Write the code for accepting inputs, printing outputs and calling the non-static
methods in the main method from the Manufacturer Tester class.
-You can refer to the sample input/output below to verify your solution.
-Don't use any static test or formatting for printing the result. Just invoke the
methods and prime result.
-All comparisons should be case-insensitive.
Sample Input 1:
2
2001
Dell
2
Laptop
800
Monitor
300
2002
HP
2
Printer
150
Laptop
750
2001
Laptop
Sample Output 1:
550.0
Dell
HP
Sample Input 2:
2
5001
Tesla
2
Model S
80000
Model X
90000
5002
Ford
2
Mustang
40000
F-150
45000
6000
Cybertruck
Sample Output 2:
Manufacturer Not Found
Product Not Found