Question

#include <iostream>#include <string>using namespace std;struct Node{ string patientName;

int SSN, age, smoker, HBP, HFD, points = 0;

Node* link;

};


Node* head = NULL;

//Function Prototypes

void displayMenu();

void createNewNode(Node* newNode);

void createPatient();

void displayPatient();

void exitProgram();


int main()

{

int choice;

while (true)

{

displayMenu();

cout << "Enter a choice from 1 to 3: ";

cin >> choice;


switch (choice)

{

case 1:

createPatient();

break;

case 2:

displayPatient();

break;

case 3:

exitProgram();

break;

default:

cout << "Invalid entry. Enter a number between 1 and 7." << endl;

}

}

return 0;

}


void displayMenu()

{

cout << "          Patient Records Manager          " << endl << endl;

cout << "What would you like to do? " << endl << endl;

cout << "[1] Add a new patient." << endl <<

"[2] Display Patient data." << endl <<

"[3] Exit." << endl << endl;

}


void createNewNode(Node *newNode)

{

//cin.clear();

cout << "Enter the patient's name: "<< endl;

getline (cin, newNode->patientName);

cout << "Enter the last 4 digits of the patient's SSN: ";

cin >> newNode->SSN;

cout << "Enter the patient's age: ";

cin >> newNode->age;

cout << "Enter patient's smoker status (Type 1 for Smoker and 0 for Non-Smoker): ";

cin >> newNode->smoker;

cout << "Enter patient's HBP status (Type 1 for HBP and 0 for NO HBP): ";

cin >> newNode->HBP;

cout << "Enter patient's HFD status (Type 1 for HFD and 0 for NO HFD): ";

cin >> newNode->HFD;

newNode->link = NULL;

}


void createPatient()

{

Node* newNode = new Node;

//If list is empty, create the very 1st Node and point the Head pointer to this 1st node

if (head == NULL)

{

createNewNode(newNode);

head = newNode;

newNode->link = NULL;

}

else //If list is not empty, create an additional node and insert it at the end of the list

{

createNewNode(newNode);

Node* temp = head;

while (temp->link != NULL)

temp = temp->link;

temp->link = newNode;

newNode->link = NULL;

}


int choice;

cout << "Would you like to add another patient? (Type 1 for Yes and 0 for No): ";

cin >> choice;

if (choice == 1)

createPatient();

}


void displayPatient()

{

}


void exitProgram()

{

}

#include <iostream> #include <string> using namespace std; struct Node { string patientName; int SSN, age, smoker, HBP, HFD, points = 0; Node* link;...
Get unstuck

338,976 students got unstuck by Course
Hero in the last week

step by step solutions

Our Expert Tutors provide step by step solutions to help you excel in your courses