TCS Proctored assessment 3rd July | Java program
My channel : / @onestopjavasolutionsbysneh1084
Previous Video : • TCS Proctored assessment 5th June | J...
Next Video : • Variable Length Arguments (varargs) i...
JAVA PA: 3rd July
Create a class NavalVessel with the below attributes:
int vesselld
String vesselName
int noOfVoyagesPlanned
int noOfVoyagesCompleted
String purpose
String classification
Write getters, setters for the above attributes . Create constructor which takes parameter in the above sequence except classification.
Create class Solution with main method. Implement two static methods – findAvgVoyagesByPct and findVesselByGrade in Solution class.
findAvgVoyagesByPct method: This method will take two input parameters -array of NavalVessel objects and int parameter percentage. The method will return the average of the noOfVoyagesCompleted attribute from NavalVessel objects which meets the percentage requirement as mentioned below.
The percentage for each navalVessel is calculated as percentage .(noOfVoyagesCompleted * 100)/noOfVoyagesPlanned
If the above calculated percentage is greater than or equal to the percentage passed as the parameter, then those objects should participate in the average calculation. If there are no objects with the mentioned criteria, then the method should return 0.
If the returned value is 0 then it should print “There are no voyages completed with this percentage” . Else it print the average of the noOfVoyagesCompleted .
findVesselByGrade method: This method will take a String parameter purpose, along with the array of NavalVessel objects. The method will return the NavalVessel object, if the input String parameter matches with the purpose attribute of the NavalVessel object.
Before returning the object, the classification should be derived as mentioned below. This classification value should be assigned to the object before returning. If any of the above conditions are not met, then the method should return null.
The classification attribute should be calculated based on the percentage calculation mentioned above. If the percentage = 100 then classification should be ‘Star’, if percentage in between 99 and 80 then classification should be ‘Leader, if percentage is between 79 and 55 then classification should be ‘Inspirer otherwise the classification should be ‘Striver’
If the returned value is null then it should print “No Naval Vessel is available with the specified purpose”. Else it print vesselName concatenate with classification in the form of “vesselName% classification” like “Yashwin%Inspirer”.
Before calling these static methods in main, use Scanner object to read the values of four NavalVessel objects referring attributes in the above mentioned attribute sequence (except the classification attribute). Next, read the value for percentage and purpose.
Consider below sample input and output:
Input:
111
Rojer
100
100
Passenger
222
Kalam
200
100
Goods
333
Yashwin
400
300
Army
444
Thanishwini
500
500
Welfare
75
Army
Output:
300
Yashwin%Inspirer
Auf dieser Seite können Sie das Online-Video TCS Proctored assessment 3rd July | Java program mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer One stop java solutions By Snehashis 10 Juli 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 332 Mal angesehen und es wurde von 10 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!