View the step-by-step solution to:

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()

{

}

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes