Hi,
I have created the program with just files, please see the output screenshots before executing the program.
Program:
//header files
#include <iostream>
#include<string>
#include <fstream>
#include <cstring>
using namespace std;
//function to display menu
char hospital_menu()
{
cout << "\nArkansas Children Hospital" << endl
<< endl;
cout << "a. Add new patient record" << endl;
cout << "b. search record" << endl;
cout << "c. Deletea record" << endl;
cout << "d. Print all records" << endl;
cout << "e. Exit " << endl;
char ch;
cout << "Enter your choice HERE=> ";
cin >> ch;
return ch;
}
//function to add new paient
void add_new_patient()
{
int id;
string name;
string address;
string dob;
string gender;
cout << "Enter patient details.."<<endl;;
cout << "Enter id: ";
cin >> id;
while ((getchar()) != '\n');
cout << "Enter name: ";
getline(cin, name);
cout << "Enter address: ";
cin >> address;
cout << "Enter date of birth: ";
cin >> dob;
cout << "Enter gender: ";
cin >> gender;
std::fstream fs;
fs.open("Patient.txt", std::fstream::in | std::fstream::out |
std::fstream::app);
fs << id << " " << name << " " << address << " " << dob << " " << gender << endl;
fs.close();
}
//function to search for a patient
void search_patient()
{
std::fstream fs;
fs.open("Patient.txt", std::fstream::in | std::fstream::out |
std::fstream::app);
string d;
cout << "Enter patient dob: ";
cin >> d;
int id;
string fname;
string lname;
string address;
string dob;
string gender;
string fn, ln;
while (fs >> id >> fname >> lname >>
address >> dob >> gender)
{
int result = dob.compare(d);
if (result == 0)
{
cout << "Enter first name: ";
cin >> fn;
cout << "Enter last name: ";
cin >> ln;
string ff = fn + ln;
string ff1 = fname + lname;
result = ff.compare(ff1);
if (result == 0)
{
cout << "Record found..." <<endl;
cout << "Id:" << id << "\nName: " << fname
<< " " << lname << "\nAddress: " << address
<< "\nDOB: " << dob << "\nGender: " <<
gender << endl;
return;
}
}
}
cout << "This is a new patient, please select option \'a\' from the menu." << endl;
fs.close();
}
//function to delete a patient based on id
void delete_patient_record()
{
std::fstream fs;
fs.open("Patient.txt", std::fstream::in | std::fstream::out |
std::fstream::app);
int d;
cout << "Enter patient id: ";
cin >> d;
int id;
string fname;
string lname;
string address;
string dob;
string gender;
string fn, ln;
while (fs >> id >> fname >> lname >>
address >> dob >> gender)
{
if (d == id)
{
break;
}
else
{
cout << "Patient record with id " << d << " not
found!!" << endl;
return;
}
}
std::fstream fs1;
fs1.open("Patient.txt", std::fstream::in | std::fstream::out |
std::fstream::app);
ofstream temp;
temp.open("temp.txt");
while (fs >> id >> fname >> lname >>
address >> dob >> gender)
{
if (d != id)
{
temp << id << " " << fname << " "
<< lname << " " << address << " " <<
dob << " " << gender << endl;
}
}
temp.close();
fs1.close();
remove("Patient.txt");
rename("temp.txt", "Patient.txt");
}
//function to print all patient records
void print_all_record()
{
std::fstream fs;
fs.open("Patient.txt", std::fstream::in | std::fstream::out |
std::fstream::app);
int id;
string fname;
string lname;
string address;
string dob;
string gender;
string fn, ln;
cout << "Id "
<< "Name\t"
<< "Address\t\t\t"
<< "DOB\t\t"
<< "Gender" << endl;
while (fs >> id >> fname >> lname >>
address >> dob >> gender)
{
cout << id<<" " << fname <<" " <<
lname<< "\t" << address <<"\t\t" << dob
<<"\t"<< gender << endl;
}
}
//main method
int main()
{
while(true){
char ch = hospital_menu();
if(ch != 'a' && ch != 'b' && ch != 'c' &&
ch != 'd' && ch != 'e')
break;
switch (ch)
{
case 'a':
add_new_patient();
break;
case 'b':
search_patient();
break;
case 'c':
delete_patient_record();
break;
case 'd':
print_all_record();
break;
case 'e':
return 1;
break;
default:
break;
}
}
return 0;
}

Output Screenshots:




Actual file content:

C++ program Write a C++ program to manage a hospital system, the system mainly uses file...
In C++ write a simple menu program that displays a menu for the user in an object-oriented technique. The menu should keep showing up until the user chooses to quit. Also, there is a sub-menu inside a menu. The user should get at least a line displayed after he or she chooses that particular option meaning if the user presses 1 for the read actors from the file. The output can look like "reading actors from a file" and then...
write a c++ program :Assume one of the companies is renting flats for people asks you to develop a small system to help them track who paid the rent fees, and who did not for the coming month. The data in this system includes: ID number of the person who rented the house, flat number , fine to be paid, tenant name, status of payment(paid or unpaid ). The main interface of the system should be as follows: 1- Add...
please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...
C++
developing involves ut from a file a person's first name, last name, phone number and birth a menu driven database application. You need to 4) This program accept as input ogram will be menu driven with the following options: 1) Find a person's information 2) Add a person to the database 3) Edit a person's information 4) Display all records to the screen 5) Quit Option 1 allows the user to enter a name after which you will search...
DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...
: Files and Exceptions: Write a program to create and use a grade book for a course. The gradebook is created as a file named as “Course_Name.dat” and includes the following information about students: Student ID, First Name, Last Name, and Grade. Assume the following structure for the gradebook file:1.Students’ records are separated by a new-line character.2.No field includes any white-space character, and fields are separated by space.3.The order of the fields is the same for all the records.Based on...
Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the system by entering his or her user-id and a secret password, the system must check the validity of this user-id and password to verify that this is a legitimate user. Because this validation must be done many times each day, it is necessary to structure this information in...
Looking for some help with this Java program I am totally lost
on how to go about this.
You have been approached by a local grocery store to write a program that will track the progress of their sales people (SalesPerson.java) The information needed are: D Number integer Month 1 Sales Amount-Double Month 2 Sales Amount-Double Month 3 Sales Amount-Double Write a Java program that allows you to store the information of any salesperson up to 20 While the user...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++ required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....