Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have been given 2 files to work with, contacts.txt and users.txt. - Write all code in a single main.cpp file. (Using Linked Lists) -

You have been given 2 files to work with, contacts.txt and users.txt.

- Write all code in a single main.cpp file. (Using Linked Lists) - You will have 2 linked lists in the program (one to store user details, one for contacts).

contacts.txt

user_id contact_with contact_start contact_end distance(cm) 1007 1010 1630731125 1630731129 202 1003 1010 1630718920 1630719418 309 1020 1012 1630713119 1630713527 119 1010 1018 1630705321 1630705464 217 1007 1013 1630730361 1630730363 335 1006 1015 1630707356 1630707360 258 1014 1001 1630717612 1630717615 306 1020 1011 1630700732 1630701123 42 1005 1011 1630717455 1630717459 68 1015 1006 1630706680 1630706686 217

users.txt

user_id fname lname gender age phone address 1001 Ray Dixon M 46 9364652 Lokia 1002 Bryan Green M 18 9579302 Drekena 1003 Justin Dixon M 33 9353533 Lokia 1004 Lester Byrd M 45 9534695 Nasilai 1005 Santos Larson M 53 9093177 Vunuku 1006 Bryan Cobb M 42 9905139 Narocivo 1007 Eddie Watson M 20 9610408 Nabua 1008 Wesley Barton M 27 9801864 Nasigatoka 1009 Victor Mason M 50 9855386 Nukutubu 1010 Ellis Cobb M 24 9389406 Narocivo 1011 Diana Ross F 27 9940148 Vunuku 1012 Amanda Carter F 43 9506743 Nasilai 1013 Maria Edwards F 53 9798534 Narocivo 1014 Maria Jenkins F 34 9352516 Lomanikoro 1015 Louise Davis F 55 9812126 Nasilai 1016 Sandra Sanders F 29 9369570 Tavuya 1017 Bonnie Roberts F 40 9689234 Nukui 1018 Melissa Harris F 29 9321235 Drekena 1019 Marilyn Parker F 56 9409221 Nukui 1020 Bonnie Lopez F 43 9342939 Nasigatoka

Constraints: - The problem must be solved using Linked Lists (either singly or doubly. Recommended to use doubly linked list). - The program must work with any number of lines in the files. - Do not edit the input files. The file has arbitrary number of empty lines at the end. This is done intentionally. - The files contacts.txt and users.txt must be placed along with your main.cpp file. That is, in the same location. The files must also be named as contacts.txt and users.txt respectively, in small caps in your source code. Do not rename the files to any other name.

Requirements:

The program must print a welcome message to the user of the program and then display 6 menus items to choose from. All menu items must be implemented as functions. The program must have 6 menu items, as follows:

1. Exit the program - the program must exit when the user enters 1.

2. Print the users - this function should print all the users from the users.txt file. Display all the columns.

3. Print all the contacts - this function should print all the contacts from the contacts.txt file. Display the user_id, contact_with, duration in seconds, distance in cm.

4. Print the contacts who 'came into contact' - this function should filter out and print only those contacts who "came into contact". Two individuals are said to have come into contact if: a. They have been in proximity for more than or equal to 15 seconds, or, b. The distance between the two was less than 100cm, regardless of the contact duration.

Display the user_id, contact_with, duration in seconds, distance in cm.

5. Search by userID - after the contacts have been identified, the Health Ministry would like to reach the individuals to provide necessary medical care. This function should allow the program user to search and print the details of the contacts. Display the user_id, full name, gender, age, phone, address.

6. Print the users in reverse - this function should print all the users from the users.txt file, but in reverse order. Display all the columns. (ie. 1020 will be printed first and 1001 will be last).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions