Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a UML Diagram of this program. Make sure it is neat and clear to understand. //Node.h #pragma once #includepatient_list.h class node { public: patient_list

Make a UML Diagram of this program. Make sure it is neat and clear to understand.

//Node.h

#pragma once #include"patient_list.h" class node { public: patient_list data; node * next; }; node* append(node* head, patient_list data) { node* temp = new node; temp->data = data; temp->next = NULL; if (head == NULL) { head = temp; return head; } node* last = head; while (last->next != NULL) { last = last->next; } last->next = temp; cout << "Append completed" << endl; return head; }

void update(node* head, string data, string newData) { while (head != NULL) { if (head->data.name == data) { head->data.name = newData; break; } head = head->next; } } int listLength(node* head) { int temp = 0; if (head == NULL) { cout << "Node is empty" << endl; return 0; } while (head->next != NULL) { ++temp; head = head->next; } return temp + 1; } void deletee(node* head, int loc) { node* temp = new node; temp = head; if (head == NULL) {

cout << "Node is null" << endl; return; } for (int i = 1; i <= loc; ++i) { temp = temp->next; if (i < loc) { head = head->next; } } head->next = temp->next; } node* search(node* head, string v) { if (head == NULL) { cout << "Node is empty returning null" << endl; return NULL; } int l = 1; while (head->next != NULL && head->data.name != v) { head = head->next; ++l; } cout << "Element found at location " << l << endl; return head; } void printLinkedList(node* head) { if (head == NULL) { cout << "Head is null" << endl; return; } while (head->next != NULL) { cout << "Name: " << head->data.name << ", City: " << head->data.city << ", Immune Level: " << head->data.immune_level << ", Symptoms: " << head->data.symptoms << ", Severity: " << head->data.severity << ", Age: " << head->data.age << ", Admit No: " << head->data.admit_no << endl; head = head->next; } cout << "Name: " << head->data.name << ", City: " << head->data.city << ", Immune Level: " << head->data.immune_level << ", Symptoms: " << head->data.symptoms << ", Severity: " << head->data.severity << ", Age: " << head->data.age << ", Admit No: " << head->data.admit_no << endl; } void filewrite(node * head) { ofstream fout; fout.open("patients.txt"); while (head->next != NULL) { fout << "Name: " << head->data.name << ", City: " << head->data.city << ", Immune Level: " << head->data.immune_level << ", Symptoms: " << head->data.symptoms << ", Severity: " << head->data.severity << ", Age: " << head->data.age << ", Admit No: " << head->data.admit_no << endl; head = head->next; } fout << "Name: " << head->data.name << ", City: " << head->data.city << ", Immune Level: " << head->data.immune_level << ", Symptoms: " << head->data.symptoms << ", Severity: " << head->data.severity << ", Age: " << head->data.age << ", Admit No: " << head->data.admit_no << endl; fout.close(); } patient_list inputPatients() { string name, city, symptoms, immune_level, severity; int admit_no, age; patient_list p; cout << "Enter Patient Name: "; cin.ignore(); getline(cin, name); cout << "Enter Patient City: "; getline(cin, city); cout << "Enter Patient Symptoms: "; getline(cin, symptoms); cout << "Enter Patient Immune Level: "; getline(cin, immune_level); cout << "Enter patient Severity: "; getline(cin, severity); cout << "Enter Patient Admit No.: "; cin >> admit_no; cout << "Enter Patient Age: "; cin >> age; p.name = name; p.city = city; p.symptoms = symptoms; p.immune_level = immune_level; p.severity = severity; p.admit_no = admit_no; p.age = age; cout << "Completed input operation" << endl; return p; } bool authenticateUser() { string username, password; cout << "Enter Username: "; getline(cin, username); cout << "Enter Password: "; getline(cin, password); if (username.compare("admin") == 0 && password.compare("pass123") == 0) { return true; } return false; } void countPatients(node* head) { int maxCityIndex = 0;//index of city with max patients int minCityIndex = 0;//index of city with min patients int len = listLength(head);//length of list int index = 0; int *countPatientCity = new int[len];/*maximum different cities count and patients in each city can be equal to length of list*/ for (int i = 0; i < len; i++) { countPatientCity[i] = 0; } string *cities = new string[len];//maximum different cities can be equal to length of list for (int i = 0; i < len; i++) { cities[i] = ""; } node *temp = head; while (temp != NULL) { int j = 0; for (; j < index; j++) { if (cities[j] == temp->data.city)//check if patients exist with same city { countPatientCity[j]++;//if yes then increment the patient count break; } } if (j == index)/*if city did not have a patient before, means new city with different patient*/ { countPatientCity[index]++;//increment patient count for new city cities[index] = temp->data.city;//save city name index++;//increment city count } temp = temp->next;//move ahead in list } for (int i = 0; i < index; i++) { cout << " City" << i + 1 << ": " << cities[i] << ", Patients : " << countPatientCity[i]; if (countPatientCity[minCityIndex] > countPatientCity[i])//checks which city has minimum count { minCityIndex = i; } else if (countPatientCity[maxCityIndex] < countPatientCity[i])//checks which city has maximum count { maxCityIndex = i; } } cout << " City with maximum patients : " << cities[maxCityIndex]; cout << " City with Minimum patients : " << cities[minCityIndex] << endl; }

//patient_list.h

#pragma once #include #include #include using namespace std; class patient_list { public: string name, city, symptoms, immune_level, severity; int admit_no, age; };

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions