TCS Proctored assessment 11th December | Java program
My channel : / @onestopjavasolutionsbysneh1084
Previous Video : • TCS Proctored assessment 14th November | J...
Next Video : • TCS Proctored assessment January 2021 | Ja...
2. OPA - Java : Item Management
Create a class Item with the below attribute
itemId - int
itemName - String
ItemType - String
itemPrice - double
The above attributes should be private, write getters, setters and parametrized constructor as required.
Create class Solution with main method.
Implement two static methods - findAvgltemPriceByType and searchltemByName in Solution class.
findAvgitemPriceByType method: This method will take two input parameters - array of Item objects and a String parameter itemType.
The method will return the average itemPrice of Items (as int) from array of Item objects for the given itemType (the String parameter passed).
If no Item with the given itemType is present in the array of Item objects, then the method should return 0.
searchltemByName method: This method will take a String parameter and an array of Item objects as the other parameter.
The method will return an Item object array in ascending order of their itemid,
from the array of Item objects whose itemName attribute matches with the String parameter passed.
If no item with the given String parameter is present in the array of Item objects, then the method should return null.
Note : No two Item object would have the same itemId.
All the searches should be case insensitive.
The above mentioned static methods should be called from the main method.
For findAvgltemPriceByType method - The main method should print the average itemPrice of Items as it is, if the returned value is greater than 0,
or it should print "There are no items with given type".
For searchltemByName method - The main method should print the itemId from the returned Item object array if the returned value is not null.
If the returned value is null then it should print "There are no items with the given name".
Before calling these static methods in main, use Scanner object to read the values of four Item objects referring attributes in the above mentioned
attribute sequence. Next, read the value for two string parameter for capturing the Item type and Item name respectively.
Consider below sample input and output:
Input:
1002
Gulabjam
Sweet
800
1001
Gulabjam
Sweet
700
1003
Kalakandi
Sweet
1100
1004
MoongDal
Hot
750
Sweet
Gulabjam
Output:
866
1001
1002
Auf dieser Seite können Sie das Online-Video TCS Proctored assessment 11th December | Java program mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer One stop Java & Math solutions By Snehashis 27 Dezember 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 450 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!