0% found this document useful (0 votes)
97 views3 pages

Compare Phone Number

The document describes a Java program to compare phone numbers of two User objects. It includes a User class with private variables for user details and a comparePhoneNumber method. The main method gets user input to create two User objects and calls comparePhoneNumber, printing "Same Users" if the phone numbers match or "Different Users" if they don't.

Uploaded by

shaik reshma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views3 pages

Compare Phone Number

The document describes a Java program to compare phone numbers of two User objects. It includes a User class with private variables for user details and a comparePhoneNumber method. The main method gets user input to create two User objects and calls comparePhoneNumber, printing "Same Users" if the phone numbers match or "Different Users" if they don't.

Uploaded by

shaik reshma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Compare Phone Number

New App helps you discover great places to eat around or de-stress in
all major cities across 20000+ merchants. Explore restaurants, spa &
salons, and activities to find your next fantastic deal. Write a program
to find the duplication of user accounts.

Write a Java program to get two users’ details and display whether


their phone numbers are the same or not with the following class and
methods.

[Note: Strictly adhere to the object-oriented specifications given as a part


of the problem statement.
Follow the naming conventions as mentioned. Create separate classes in
separate files.]

Consider the class User with the following private attributes/variables.


Date Type Variable
String     name
String     username
String     password
Long     phoneNumber

Include appropriate getters and setters.


Prototype for the Parameterized Constructor,
public User(String name, String username, String password, Long
phoneNumber)

Define the following method in the User class.


Method Name   Description
public boolean comparePhoneNumber(User In this method, compare the phone number
user) else return false
Consider the Main class and write the main method to test the above
class.

In the main method


     Obtain the details of the user.
     Create an object for the User class using the parameterized
constructor(name, username, password, phoneNumber).
     Call the method comparePhoneNumber() in the Main class.
 

The link to download the template code is given below


Code Template

Input and Output Format

Refer sample input and output for formatting specifications.


If both phone numbers are the same then print “Same Users” else print
“Different Users”.
The output should be printed in the Main class.

Sample Input/Output 1:
[All text in bold corresponds to the input and the rest corresponds to
output.]

Enter Name
john
Enter UserName
john@123
Enter Password
john@123
Enter PhoneNumber
9092314562
Enter Name
john
Enter UserName
john@12
Enter Password
john@12
Enter PhoneNumber
9092314562
Same Users

Sample Input/Output 2:

Enter Name
william
Enter UserName
william####
Enter Password
william
Enter PhoneNumber
9092314562
Enter Name
john
Enter UserName
john@123
Enter Password
john@123
Enter PhoneNumber
9092312102
Different Users

You might also like