Write a C++ program to get a list of usernames from the user, store it in a set and print the size of the set. Print " Invalid number " if the number of usernames to be added is less than or equal to zero. In the main method, obtain input from the user in the console and insert the username into the set. Display the size of the set in the main method. Problem constraints: Use container to store the values. Use insert() method to insert the values.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

QUESTION PROVIDED IN ATTACHMENT . KINDLY SEE

It's Allen's mother's 50th birthday and they planned to throw a surprise party for her. Since
they want to invite all her friends, relatives, and acquaintances, they decide each and every
family member will keep telling the name of people who know Allen's mother and make a list.
Since every person can suggest any number of names and two people can suggest the same
name so to avoid the confusion Allen's Uncle suggests to make a set of names which stores
only unique element.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All
class names, member variable names, and function names should be the same as specified
in the problem statement.
Write a C++ program to get a list of usernames from the user, store it in a set and print the
size of the set. Print " Invalid number " if the number of usernames to be added is less than or
equal to zero.
In the main method, obtain input from the user in the console and insert the username into
the set. Display the size of the set in the main method.
Problem constraints:
Use <set> container to store the values.
Use insert() method to insert the values.
Input format:
The first line of input consists of an integer n that corresponds to the number of usernames to
be added
Next, n lines correspond to a string that corresponds to the username.
Output format:
The output consists of an integer that corresponds to the size of the set.
If the number of usernames to be added is less than or equal to zero display "Invalid number
Refer sample Input and Output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1:
Enter the number of usernames to be added:
3
Enter the name of user 1
Enter the name:
arjun
Enter the name of user 2
Enter the name:
siva
Enter the name of user 3
Enter the name:
siva
Size of the set is:2
Sample Input and Output 2:
Enter the number of usernames to be added:
-5
Invalid number
Transcribed Image Text:It's Allen's mother's 50th birthday and they planned to throw a surprise party for her. Since they want to invite all her friends, relatives, and acquaintances, they decide each and every family member will keep telling the name of people who know Allen's mother and make a list. Since every person can suggest any number of names and two people can suggest the same name so to avoid the confusion Allen's Uncle suggests to make a set of names which stores only unique element. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Write a C++ program to get a list of usernames from the user, store it in a set and print the size of the set. Print " Invalid number " if the number of usernames to be added is less than or equal to zero. In the main method, obtain input from the user in the console and insert the username into the set. Display the size of the set in the main method. Problem constraints: Use <set> container to store the values. Use insert() method to insert the values. Input format: The first line of input consists of an integer n that corresponds to the number of usernames to be added Next, n lines correspond to a string that corresponds to the username. Output format: The output consists of an integer that corresponds to the size of the set. If the number of usernames to be added is less than or equal to zero display "Invalid number Refer sample Input and Output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output] Sample Input and Output 1: Enter the number of usernames to be added: 3 Enter the name of user 1 Enter the name: arjun Enter the name of user 2 Enter the name: siva Enter the name of user 3 Enter the name: siva Size of the set is:2 Sample Input and Output 2: Enter the number of usernames to be added: -5 Invalid number
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY