Professional Documents
Culture Documents
int phoneId
String os
String brand
int price
Write getters, setters and parameterized constructor in the above mentioned
attribute sequence as required.
Create class Solution with main method
2. Take necessary input variable and call getPhoneBasedOnOs. For this method-
The main method should print the id of return phone object as it is if the returned
value is not null, or it should print "No phones are available with specified os ”.
Note- All the searches should be case insensitive. Before calling these static
methods in main, use Scanner object to read the values of four Phone objects
referring attributes in the above mentioned attribute sequence. Next, read the value
for brand and os.
4
111
iOS
Apple
30000
222
android
Samsung
50000
333
Symbian
HTC
12000
444
Paranoid
HTC
89000
Blackberry
aNdRoid
Output
222
Program-
import java.util.*;
class Phone{
int phoneId;
String os;
String brand;
int price;
String brand=sc.nextLine();
String os=sc.nextLine();
sc.close();
int price=findPriceForGivenBrand(p,brand);
if(price!=0)
{
System.out.println(price);
}
else
{
System.out.println("The given Brand is not
available");
}
Phone result=getPhoneBasedOnOs(p,os);
if(result!=null)
{
System.out.println(result.getPhoneId());
}
else
{
System.out.println("No phones are available
with specified os");
}
}
return price;
}
if(m==null)
{
return null;
}
else
return m;
}