Question: This program is in C++ I started it but need help with the Functions and calling to back to the menu. Thanks The program will

This program is in C++ I started it but need help with the Functions and calling to back to the menu. Thanks

The program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to MCC Hospital. Please choose from the following options: 1. Add patient records 2. View patient records 3. Download statistics 4. Find patient 5. Exit the program Program Options Option 1: Add Patient Records If the user chooses this option, the program will a. Prompt the user for the file that contains the patient records. b. Read in the records into a 2-dimensional array. Note: You can assume that the file will NOT contain more than 100 records. Input File Format: LastName FirstName Age DailyRate Sample Input File: Bob Mike 36 140.23 Matt Benjamin 24 90.00 Keller Helen 89 98.10 Tim Mary 45 23.10 Write a function called AddPatientInfo to do this task. Choose the appropriate parameters and return type. Once done reading in the file, the main menu will be displayed again. Option 2: View Patient Records If the user chooses this option, the program will print to the screen the names of the patients and their information. Sample Output: Patient Name: Mike Bob, Age: 36, Daily Rate: 140.23 Patient Name: Benjamin Matt, Age: 24, Daily Rate: 90.00 Patient Name: Helen Keller, Age: 89, Daily Rate: 98.10 Patient Name: Mary Tim, Age: 45, Daily Rate: 23.10 Write a function called PrintPatientInfo to do this task. Choose the appropriate parameters and return type. Once done printing, the main menu will be displayed again. Option 3: Download Statistics: If the user chooses this option, the program will create a statistics file with the following data: a. Sorted patient names alphabetically (by last name) b. Youngest patient age c. Average daily price per patient The statistics file will have the same name as the input file but with _stats.txt appended to it. For example, if the input file was named patients.txt, the stats file will be named patients_stats.txt. Note: It will remove the .txt from patient.txt, before adding the _stats.txt. It will NOT create a file with the name patient.txt_stats.txt. You can use the string substr method to remove the last 4 characters from the file name. Write a function called CreateStatsFile to do this task. Choose the appropriate parameters and return type. Once done creating the statistics file, the main menu will be displayed again. Option 4: Find Patient If the user chooses this option, the program will ask for the patients last name and will search for it. It will display a message indicating whether the patient was found or not. Write a function called FindPatient to do this task. Choose the appropriate parameters and return type. Once done searching, the main menu will be displayed again. Option 5: Exit the Program If the user chooses this option, the program will exit. Note: If any other option (other than exit) is chosen, the task will be performed and then the menu will be displayed again. What to Hand in: You will hand in, through blackboard, your cpp file as well as the statistics file and a screen shot of running your program using the following sequence of steps: 1. Option 1 to add patients from patient.txt provided with this project 2. Option 2 to view patient records 3. Option 4 to search for a patient 4. Option 3 to download the statistics file 5. Option 5 to exit

Hospital Records Bob Mike 36 140.23 Matt Benjamin 24 90 Keller Helen 89 98.15 Tim Mary 45 23.1 James Alan 23 47.77 William Carla 56 94.92 Mathew Robin 73 53.7 Jacob Tom 61 79.98 Nathan Norman 9 230.1 Nick Nate 18 537 Ethan Mary 66 87.9 Kate Helen 78 20.8 Benjamin Alan 54 90.44 John Jamie 23 89.88 Tom Annie 3 100 Morgan James 19 12.8 John Nixon 100 54.88 */

#include #include #include #include #include

using namespace std;

//Function prototypes

double AddPatientInfo();

double PrintPatientInfo();

double CreateStatsFile();

double FindPatient();

int main()

{ bool quit = false; //Menu Options 1 while (!quit)

{ cout << "Welcome to MCC Hospital. Please choose from the following options: " << endl;

cout << " 1. Add patients records" << endl; cout << " 2. View patient records" << endl;

cout << " 3. Download statistics" << endl;

cout << " 4. Find patient" << endl;

cout << " 5. Exit the program " << endl;

cout << "Please enter the file name you would like to read. " << endl;

int a; cin >> a;

switch (a)

{ case 1: cout << << endl; int b; cin >> b; cout << << endl; break;

case 2: cout << << endl; int c; cin >> c; cout << << endl; break;

case 3: cout << << endl; int d; cin >> d; cout << << endl;

case 4: cout << << endl; int e; cin >> e; cout << << endl; break;

case 5: cout <<"Are you sure you would like to exit? " "Press 'y' for yes and any "

"other key for no. "<< endl; char c; cin >> c; if (c == 'y') { quit = true; { else break; } } default: cout << "Error "; break; } } /

/File to be opened string fileName; cin >> fileName; //Input and open file ifstream input; input.open(fileName); // check if it opened if (input.fail()) { cout << "Invalid! Enter a valid file. " << endl; cin >> fileName; return 0; } ofstream output; output.open("C:\\Users\\Vytis\\Desktop\\patientrecords_stats.txt"); if (output.fail()) { cout << "Error" << endl; return 0; }

//Read records into two dimensional array int a, b, c, d, e; cin << a << b << c << d << e; cout << "Please enter the file name you would like to read. " << endl; //Call to function AddPatientInfo(); //View Patient Records cout << "Patient Name: " << << endl;

//Call to function PrintPatientInfo();

//Call funtion CreateStatsFile(); //Find patient cout << "Enter patients's last name: " << endl;

//Call funtion FindPatient(); }

//Function Definitions

double AddPatientInfo()

{ cout << "LastName FirstName Age DailyRate: " << endl;

string LaNa, FiNa, Age, DaRa;

cin >> LaNa, FiNa, Age, DaRa; return; }

double PrintPatientInfo()

{ while () { } return; }

double CreateStatsFile() { return; }

double FindPatient()

{ cout << "Patient was found. " << endl;

cout << "Patient was not found. " << endl; return; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!