0% found this document useful (0 votes)
175 views

Mock2 SBQ Java 21 Nov MUM With Answers

The document describes a coding challenge to create Vehicle and Solution classes in Java. It involves creating methods to find the vehicle with minimum price and search for a vehicle by name. Sample inputs and expected outputs are provided to test the code. The second part describes a challenge to write a Bash script to fetch student details from a file that meet certain criteria of scores and school. Sample input and output files are given.

Uploaded by

Faizal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views

Mock2 SBQ Java 21 Nov MUM With Answers

The document describes a coding challenge to create Vehicle and Solution classes in Java. It involves creating methods to find the vehicle with minimum price and search for a vehicle by name. Sample inputs and expected outputs are provided to test the code. The second part describes a challenge to write a Bash script to fetch student details from a file that meet certain criteria of scores and school. Sample input and output files are given.

Uploaded by

Faizal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Mock2_SBQ_Java_21_Nov_… 65 minutes

Question - 1 SCORE: 35 points


Java_PRA2_Vehicle_min_Search

Java 8 Java

Create a class Vehicle with below attributes:


number - int
name - String
price - double

Write getters, setters and parameterized constructor in the above


mentioned attribute sequence as required.
Create class Solution with main method
Implement two static methods - findVehicleWithMinimumPrice and
searchVehicleByName in Solution class.
findVehicleWithMinimumPrice
Create a static method findVehicleWithMinimumPrice in the Solution
class. This method will take array of Vehicle objects and returns the
Vehicle object having the minimum Price if found else return null if not
found.
searchVehicleByName
Create a static method searchVehicleByName in the Solution class. This
method will take array of Vehicle objects and Name as input and returns
the Vehicle object having the mentioned Name if found else return null
if not found.
These methods should be called from the main method.
Write code to perform the following tasks:
1. Take necessary input variable and call findVehicleWithMinimumPrice.
For this method - The main method should print the Vehicle object with
minimum of mentioned attribute as it is if the returned value is not null,
or it should print "No Vehicle found with mentioned attribute".
2. Take necessary input variable and call searchVehicleByName. For this
method - The main method should print the Vehicle object details as it
is, if the returned value is not null, or it should print "No Vehicle found
with mentioned attribute".
The above mentioned static methods should be called from the main
method. Also write the code for accepting the inputs and printing the
outputs. Don't use any static test or formatting for printing the result.
Just invoke the method and print the result
Note :
All String comparison needs to be case in-sensitive
You can use/refer the below given sample input and output to verify
your solution.
Sample Input (below) description:
The 1st input taken in the main section is the number of Vehicle objects
to be added to the list of Vehicle.
The next set of inputs are number,name,price for each Vehicle object
taken one after other and is repeated for number of Vehicle objects
given in the first line of input.
The last line of inputs will be the arguments which needs to be passed
as parameter to the methods.
Consider below sample input and output to test your code:

1/3
Sample Input 1 - public
4
3111
bus
1000.0
4112
crane
1800.0
5114
Tractor
2400.0
6115
Scooter
2700.0
Scooter
Sample Output 1
number-3111
name-bus
price-1000.0
number-6115
name-Scooter
price-2700.0

Sample Input 2 - public


4
1109
Train
2000.0
5104
taxi
2800.0
4112
bike
5600.0
8107
Scooter
3300.0
bike
Sample Output 2
number-1109
name-Train
price-2000.0
number-4112
name-bike
price-5600.0

Question - 2 SCORE: 15 points


PRA2-3rd_Feb-Unix - Fetch Students

Bash Medium

Contents of intput file: studentsData


StudentNo|Name|Standard|SchoolName|MathematicsScore|Science
Score
1|Latha|Third|Vikas|90|91
2|Neethu|Second|Meridian|92|94
3|Sethu|First|DAV|86|98
2/3
4|Theekshana|Second|DAV|97|86
5|Teju|First|Sangamithra|89|88
6|Theekshitha|Second|Sangamithra|99|100

Fields are separated by the field separator ("|")

Write a command to fetch the student details , who scored >=90 in


mathematics and >=90 in Science subject from Sangamithra school and
display students details.
The display record format is:
StudentNo,Name,Standard,SchoolName and Average of Marks(of two
subjects given in th input data ) of the students in the Ascending order
of the average of the scores, if there are multiple records satisfies the
given condition. If no records satisfies the given condition then output is
empty.
For more clarity, please refer to the sample testcase input and output
below.

The input file with the data(testcase input / customized input) in the
format mentioned, automatically supplied as command line argument
when you run the script / command , you have written. Hence you don't
need to worry / work on, " How to bring the file to your script"?.
You just need to assume that a file is supplied to your script and read
the file, which is supplied as command line argument and process the
data in the file towards the given requirement.

You can use shell variables (e.g. $0,$1,$2) whichever is applicable for
your requirement to provide the command line argument.

Sample Testcase:
Input:

1|Latha|Third|Vikas|90|91
2|Neethu|Second|Meridian|92|94
3|Sethu|First|DAV|86|98
4|Theekshana|Second|DAV|97|86
5|Teju|First|Sangamithra|92|94
6|Theekshitha|Second|Sangamithra|99|100

Output:

5|Teju|First|Sangamithra|93
6|Theekshitha|Second|Sangamithra|99.5

3/3

You might also like