Oops 5 Ques
Oops 5 Ques
******************************************************************
Create a class Phone with below attributes:
phoneId - int
os - String
brand - String
price - int
findPriceForGivenBrand method:
----------------------------------
This method will take two input parameters - array of Phone
objects and string
parameter brand. The method will return the sum of the price
attribute from phone objects for the brand passed
as parameter. If no phones with the given brand is present in the
array of phone objects, then the method should
return 0.
Input
--------------
111
iOS
Apple
30000
222
android
Samsung
50000
333
Symbian
HTC
12000
444
Paranoid
HTC
89000
Blackberry
aNdRoid
Ques 2.
*****************************************************************
Create a class Student with below attributes:
rollNo - int
name - String
subject - String
grade - char
date - String [DD/MM/YYYY]
findStudentByGradeAndMonth Method:
for this method- main method should print Student name, subject
and total student found [The
length of the list], if the returned value is not null. If the returned
value is null then
main method should print "No student found".
NOTE:
1. For Taking char as input use sc.nextLine().charAt(0)
2. To match/check the month You havee to convert int
month in the parameter to String.
******************************************************************
**********
input1:
111
Arijit
Math
B
22/09/2023
101
Priyanka
English
A
30/03/2022
107
output1:
Priyanka
English
Tatan
Physics
2
111
Sohel
Math
B
22/09/2022
101
Priyanka
English
A
30/03/2022
107
Gopa
History
C
12/05/2022
105
Kamal
Physics
A
27/03/2022
A
7
No student found
Ques 3.
******************************************************************
Create a class TravelAgencies with below attributes:
regNo – int
agencyName – String
pakageType – String
price – int
flightFacility – boolean
findAgencyWithHighestPackagePrice method:
agencyDetailsForGivenldAndType method:
Ques 4.
******************************************************************
Create a class Bill with below attributes:
billNo- int
name - String
typeOfConnection - String
billAmount - double
status – boolean
findBillWithMaxBillAmountBasedOnStatus method:
-----------------------------------------------------
This method will take an array of Bill objects and a boolean
parameter as parameters.
The method will return bill object array in ascending order of
their bill number from the array of Bill objects whose bill
amount is maximum in the array with the status attribute that
matches with the input parameter.
getCountWithTypeOfConnection method:
-----------------------------------------------------
This method will take two input parameters - array of Bill objects
and string parameter ( for type of connection).
The method will return the count of bills from array of bill objects
for the given type of connection.
Note :
If the returned value is null then it should print "There are no bill
with the given status".
4
111
Aman Mittal
Prepaid
914.25
true
222
Rekha Kumar
Prepaid
1425.75
false
333
Samyra Gupta
Prepaid
1305.00
true
Output:
222#Rekha Kumar
3
******************************************************************
*******************
--------------------------------------------------
Sample code snippet for reference:
Please use below code to build your solution.
--------------------------------------------------
import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
//code to read values
-------------------------------------------------
Note on using Scanner object:
Sometimes scanner does not read the new line character while
invoking methods like nextInt(), nextDouble() etc.
1234
Merin Bakers
Ques 5.
******************************************************************
create the class Song with below attributes.
songId - int
title - String
findSongDurationForArtist method:
----------------------------------------------------
This method will take two input parameters of Song objects and
String parameter.
The method will return the sum of song duration from array of
Song object for the given artist (String parameter passed).
getSongsInAscendingOrder method:
----------------------------------------------------
This method will take input parameters array, of Song objects and
String parameter.The method will return Song objects array
in an ascending order of their duration, from the array of Song
objects whose artist attribute matches with the input String
parameter.
Gauri Shankar Rai
If no Song with the given artist is present in the array of Song
objects, then the method should return null.
Note:
----------
1. No two Song object would have the same songid.
2. Combination of artist and duration should be unique.
3. All the searches should be case insensitive.
For Example,
*****************************************************************
Sample Input 1:
------------------
2150
In time
Justin Timberlake
4
250
Cry Me
Justin Timberlake
3
Sample output1:
------------------------
8.0
250
Cry Me
2150
In time
1200
Gauri Shankar Rai
Mirrors
Sample Input 2:
----------------------
2150
Cry Me
Justin Timberlake
3
1000
Why Not
Enrique Iglesius
5
1200
Mirrors
Justin Timberlake
5
1300
That's the way it is
Celion Dion
5
500
Ashes
Gauri Shankar Rai
celion Dion
3
Bryan Adams
Michael Larkson
Output 2:
-----------------------