HELLO DORAEMONS,
IN THIS BLOGPOST ,I HAVE SHARED THE RECENTLY ASKED JAVA QUESTION AND SOLUTION WHICH IS CERTAINLY USEFUL WHEN YOU WANT TO PRACTICE.HOPE THIS BLOG IS USEFUL TO YOU
Create a Class Watch with below attributes:
watchId - int
watchName - String
price - double
brand - String
The above attributes should be private, write getters, setters and parameterized constructor as required.
Create class MyClass with main method. Implement one static method - countWatchesByBrand in MyClass class.
countWatchesByBrand method: This method will take two input parameters array of Watch objects and String parameter The method will return the count of Watches from array of Watch objects for the given brand(String parameter passed) which begins with a vowel character. If no Watch with the above condition is present in the array of Watch objects, then the method should return 0.
Note : No two watch will have the same brand. All the searches should be case insensitive.
To Xpe
The above mentioned static method should be called from the main method.
on error
For countWatchesByBrand method - The main method should print the returned count as it is if the returned value is greater than 0 or it should print "No such Watch".
Eg: 3 where 3 is the count of Watch for the specified condition.
Before calling the static methods in main, use Scanner object to read the values of four Watch objects referring attributes in the above mentioned attribute sequence. Next, read the value of String parameter for capturing brand value. Consider below sample input and output:
Input:
111
Series 7
30000
Apple
222
Galaxy 3
15000
Samsung
333
Series 5
20000
Apple
444
F7
10000
Fossil
Apple
Output:
2
Input2:
111
Series 7
30000
Apple
222
Galaxy 3
15000
Samsung
333
Series 5
20000
Apple
444
F7
10000
Fossil
Fossil
Output:
No such Watch
0 Comments