Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions Write a complete C++ program that allows the user to create, modify, and query an associative dataset. The source code for the program should
Instructions Write a complete C++ program that allows the user to create, modify, and query an associative dataset. The source code for the program should be in file assoc.cpp The program should operate as follows .The program maintains an associative dataset. Both keys and values should be integers .The program presents a menu of choices to the user, allowing the user to select one of these. The choices are to set the value associated with a key, to view the value associated with a key, and to quit If the user selects set, then the program inputs a key and a value from the user, and enters these into the dataset. If the key was already in the dataset, then the new value replaces the old one .If the user selects view, then the program inputs a key from the user and prints the associated value, if the given key was in the dataset. If the key was not in the dataset, then the program notifies the user of this .If the user selects quit, then the program exits If the user did not select quit, then the program displays the menu again, gets a choice from the user, etc. The program should repeat until the user selects quit .When the program starts up, the dataset should be empty Successive set operations add to the dataset. Proper error handling should be done. In particular, if the user is asked to enter a number, and something else is typed, then the program should notify the user and retry the input. A run of the program might look like this. Boldface text is that typed by the user Associative Dataset 1 Set the value associated with a key 2 view the value associated with a key 3 Quit Choice: 2 Enter a key (integer): abe Please enter an integer Enter a key (integer): 2 Key 2 is not in the dataset 1 Set the value associated with a key 2 view the value associated with a key 3 Quit Choice:1 Enter a key (integer): 2 Enter the associated value (integer) 15 Entered into dataset: key 2, value 15 1 Set the value associated with a key 2 View the value associated with a key 3 Quit Choice: 2 Enter a key (integer): 2 Key 2 is in the dataset; associated value: 15 1 Set the value associated with a key 2 view the value associated with a key 3 Quit Choice:1 Enter a key (integer): 2 Enter the associated value (integer) 100 Entered into dataset: key 2, value 100 1 Set the value associated with a key 2 View the value associated with a key 3 Quit Choice: 1 Enter a key (integer): 3 Enter the associated value (integer): 10 Entered into dataset: key 3, value 10 1 Set the value associated with a key 2 View the value associated with a key 3 Quit Choice: 2 Enter a key (integer)s 2 Key 2 is in the dataset: associated value: 100 1 Set the value associated with a key 2 View the value associated with a key 3 Quit Choice: 3 Bye
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started