TCS Proctored assessment 9th October | Java program
My channel : / @onestopjavasolutionsbysneh1084
Previous Video : • Explain Main Method in details | Prot...
Next Video : • TCS Proctored assessment 11th Septemb...
Question, Test case and Solution for OPA held on 9-Oct-2020
Question
Create a class TravelAgencies with below attributes:
int regNo
String agencyName
String pakageType
int price
int rating
String location
Write getters, setters and parameterized constructor in the above mentioned attribute sequence as required.
Create class Solution with main method.
Implement two static methods - findAgencyWithHighestPackagePrice and sortedAgencyDetailsByPckg in Solution class.
findAgencyWithHighestPackagePrice method: This method will take array of TravelAgencies objects and location as input parameters .
The method will return the highest price from the given array of objects for the given location. If no agencies with the given location is present in the array of TravelAgencies objects, then the method should return 0.
sortedAgencyDetailsByPckg method: This method will take two input parameters - array of TravelAgencies objects and String parameter packageType.
The method will return TravelAgencies object array in an ascending order based on their rating, from the array of TravelAgencies objects whose packageType attribute matches with the given input string parameter(packageType). If no agencies with the given packageType is present in the array of TravelAgencies objects, then the method should return null.
The above mentioned static methods should be called from the main method.
For findAgencyWithHighestPackagePrice method - The main method should print the highest price as it is, if the returned value is greater than 0, or it should print "No agencies in the given location".
For sortedAgencyDetailsByPckg method - The main method should print the TravelAgencies name from the returned TravelAgencies object array if the returned value is not null. If the returned value is null then it should print "No such agencies with the given packageType".
Before calling these static methods in main, use Scanner object to read the values of four TravelAgencies objects referring attributes in the above mentioned attribute sequence. Next, read the value for packageType and location.
Consider below sample input and output:
Input:
123
A2Z agency
Platinum
50000
5
Chennai
345
SSS agency
Gold
30000
4
Ooty
987
Best Tours
Platinum
40000
4
Karur
888
Global Tours
Silver
20000
3
Chennai
Platinum
Chennai
Output:
50000
Best Tours
A2Z agency
Nesta página do site você pode assistir ao vídeo on-line TCS Proctored assessment 9th October | Java program duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário One stop java solutions By Snehashis 26 Outubro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 439 vezes e gostou 6 espectadores. Boa visualização!