Prompt for the phone number and the name of the caller. Store this data in a way to make further processing as efficient as possible.

computer science


How did we ever get along without caller ID? Now I don’t have to answer the phone when a telemarketer calls. And, even better, I don’t need to remember anyone’s number anymore. All I have to do is look them up on the caller ID machine. Unfortunately, I might end up with the same number stored multiple times on my callback list, and “unknown callers” take up valuable space in the machine’s memory. For this project, you’re going to write a program that simulates a caller ID machine that fixes some of my pet peeves.

You will write a menu-driven program. You can receive bonus points for making a GUI for the program, but if you prefer, you can do it via text. When displaying the menu, use an abbreviated form (like (R)eceive, (D)elete, (S)how,...) to get it to fit in as few lines as possible. Along with the menu, you should display the last received call (number and name). Give an appropriate message if there are no stored calls. After an option is executed, redisplay the menu and the last call unless the user decides to quit.

1. Receive a call: Prompt for the phone number and the name of the caller. Store this data in a way to make further processing as efficient as possible. Note that the call may be immediately blocked (see option 6). A caller with the name "Unknown Caller" should automatically be blocked. 

2. Delete last call: Prompt the user to make sure they want to do this. If so, remove the most recent call from memory. This should give an error message (and not prompt for confirmation) if there are no numbers in memory. 

3. Show previous calls: Prompt for a number k; display the last k calls, starting with the most recent. If there are no calls in memory, do not prompt for k. If k is larger than the number of calls in memory, display all the calls, and then print the message: “No more calls”. 

4. Purge call: Removes all copies of the most recent call that appear somewhere else in the list. So, for example, if the list were A, B, C, A, D, B, A, C (starting with most recent), this option would turn the list into A, B, C, D, B, C. If it were A, B, C, D, B, it would remain as is. There should be no output from this option. 

5. Find number: Prompt the user for a name. Return the number associated with that name if it appears in the call list; print an appropriate response if not. Do not prompt for a name if the call list is empty. 

6. Block call: Add the last call to a “block list” (removing it from the regular list). If that number/name combination is ever received again in option 1, it should not be added to the call list (print an appropriate message when the call is received instead). Blocking a call does not purge the call from the list (as in option 4). 

7. Quit the program

Related Questions in computer science category