Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

#include #include #include using namespace std; struct Patient { string name; string visitReason; string address; int age; long phoneNumber; }; bool isInt(string input) { for (int i = 0; i &list) {...

1 answer below »
#include #include #include using namespace std;
struct Patient
{
string name;
string visitReason;
string address;
int age;
long phoneNumber;
};
ool isInt(string input)
{
for (int i = 0; i < input.length(); i++)
{
XXXXXXXXXXif (!isdigit(input[i]))
{
XXXXXXXXXXreturn false;
}
}
return true;
}
void addPatient(vecto
Patient> &list)
{
string name, address, visitReason;
int age;
long phoneNumber;
cout
"\nEnter patient Information"
endl;
cout
"Name: ";
cin.ignore();
getline(cin, name);
cout
"Reason to visit: ";
getline(cin, visitReason);
cout
"Address: ";
getline(cin, address);
cout
"Age: ";
cin
age;
cout
"Phone Number: ";
cin
phoneNumber;
Patient patient;
patient.name = name;
patient.address = address;
patient.visitReason = visitReason;
patient.age = age;
patient.phoneNumber = phoneNumber;
list.push_back(patient);

}
void displayAllPatient(vecto
Patient> &list)
{
if (list.size() ==0)
{
XXXXXXXXXXcout
"Cu
ently no patients in the list"
endl;
}
else
{
XXXXXXXXXXcout
"\nPatients in the list"
endl;
XXXXXXXXXXfor (int i = 0; i < list.size(); i++)
{
XXXXXXXXXXcout
"\n-------------------------------------------"
endl;
XXXXXXXXXXcout
"Name: "
list.at(i).name
endl;
XXXXXXXXXXcout
"Reason To Visit: "
list.at(i).visitReason
endl;
XXXXXXXXXXcout
"Address: "
list.at(i).address
endl;
XXXXXXXXXXcout
"Age: "
list.at(i).age
endl;
XXXXXXXXXXcout
"Phone Number: "
list.at(i).phoneNumber
endl;
}
}

}
void displaySinglePatient(vecto
Patient> &list)
{
if (list.size() == 0)
{
XXXXXXXXXXcout
"Cu
ently no patients in the list"
endl;
}
else
{
XXXXXXXXXXstring name;
XXXXXXXXXXcout
"Enter name of the patient: ";
XXXXXXXXXXcin.ignore();
XXXXXXXXXXgetline(cin, name);
XXXXXXXXXXbool found = false;
XXXXXXXXXXfor (int i = 0; i < list.size(); i++)
{
XXXXXXXXXXif (list.at(i).name == name)
{
XXXXXXXXXXcout
"\nPatient Information"
endl;
XXXXXXXXXXcout
"Name: "
list.at(i).name
endl;
XXXXXXXXXXcout
"Reason To Visit: "
list.at(i).visitReason
endl;
XXXXXXXXXXcout
"Address: "
list.at(i).address
endl;
XXXXXXXXXXcout
"Age: "
list.at(i).age
endl;
XXXXXXXXXXcout
"Phone Number: "
list.at(i).phoneNumber
endl;
XXXXXXXXXXfound = true;

eak;
}
}
XXXXXXXXXXif (!found)
{
XXXXXXXXXXcout
"No Patient exists with this name"
endl;
}
}
}
void deletePatient(vecto
Patient> &list)
{
if (list.size() == 0)
{
XXXXXXXXXXcout
"Cu
ently no patients in the list"
endl;
}
else
{
XXXXXXXXXXstring name;
XXXXXXXXXXcout
"Enter name of the patient: ";
XXXXXXXXXXcin.ignore();
XXXXXXXXXXgetline(cin, name);
XXXXXXXXXXbool found = false;
XXXXXXXXXXfor (int i = 0; i < list.size(); i++)
{
XXXXXXXXXXif (list.at(i).name == name)
{
XXXXXXXXXXlist.erase(list.begin() + i);
XXXXXXXXXXcout
"Record have been deleted"
endl;
XXXXXXXXXXfound = true;

eak;
}
}
XXXXXXXXXXif (!found)
{
XXXXXXXXXXcout
"No Patient exists with this name"
endl;
}
}

}
int main()
{
int input;
string str;
bool check;
vector patientList;
while (true)
{
XXXXXXXXXXcout
"\n XXXXXXXXXXWelcome"
endl;
XXXXXXXXXXcout
"1. To add a patient"
endl;
XXXXXXXXXXcout
"2. To view all patients"
endl;
XXXXXXXXXXcout
"3. To view a single patient"
endl;
XXXXXXXXXXcout
"4. To delete a patient"
endl;
XXXXXXXXXXcout
"5. To Exit the program"
endl;
XXXXXXXXXXcout
"Enter your choice: ";
XXXXXXXXXXcin
str;
XXXXXXXXXXcheck = isInt(str);
XXXXXXXXXXif (check)
{
XXXXXXXXXXinput = stoi(str);
XXXXXXXXXXswitch (input)
{
XXXXXXXXXXcase 1:
{
XXXXXXXXXXaddPatient(patientList);

eak;
}
XXXXXXXXXXcase 2:
{
XXXXXXXXXXdisplayAllPatient(patientList);

eak;
}
XXXXXXXXXXcase 3:
{
XXXXXXXXXXdisplaySinglePatient(patientList);

eak;
}
XXXXXXXXXXcase 4:
{
XXXXXXXXXXdeletePatient(patientList);

eak;
}
XXXXXXXXXXcase 5:
{
XXXXXXXXXXcout
"Thank you for using the program"
endl;
XXXXXXXXXXexit(0);
}
XXXXXXXXXXdefault:
{
XXXXXXXXXXcout
"Invalid
Answered Same Day Jun 03, 2021

Solution

Arun Shankar answered on Jun 04 2021
140 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here