Wednesday, 14 September 2016

Write a program in JAVA which accept a String address from user and return true if the address contains pincode at any position and return false if the address does not contain any pincode.

This is another tricky question for the job seekers. Concept is pretty simple here. You have to write a boolean method which will validate the address and return true if it finds PINCODE and return false it does not find.

I am using regular expression to solve this approach.

Sample input:
61 B, Palm Avenue, Joy Bijoy Apartment, 1st Floor, Flat No 1D, West Bengal

Output:
Pincode does not exist.

Sample Input:
61 B, Palm Avenue, Joy Bijoy Apartment, 1st Floor, Flat No 1D, West Bengal 700112

Output:
Pincode exist.

Sample Input:
61 B, Palm Avenue, Joy Bijoy Apartment, West Bengal 700112, 1st Floor, Flat No 1D

Output:
Pincode Exist.

Implemented code:




Sample Output 1:


Sample Output 2:


Sample Output 3:


No comments:

Post a Comment