Hello! PLEASE FIX THE ERRORS IN MY C++ PROGRAM, MAKE SURE IT COMPILES AND RUNS! CAN YOU DO THIS IMMEDIATELY? THANK YOU!!

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello! PLEASE FIX THE ERRORS IN MY C++ PROGRAM, MAKE SURE IT COMPILES AND RUNS! CAN YOU DO THIS IMMEDIATELY? THANK YOU!!

Post by answerhappygod »

Hello! PLEASE FIX THE ERRORS IN MY C++ PROGRAM, MAKE SURE IT
COMPILES AND RUNS! CAN YOU DO THIS IMMEDIATELY? THANK YOU!!
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
Public:;
string H_name;
string location;
int available_beds;
float rating;
string contact;
string doctor_name;
int price;
//Storing patient data
class Patient : public Hospital
{
Public:
string P_name;
int P_id;
}
//Hospital data
void PrintHospitalData(vector<Hospital>& hospitals)
{
cout <<"PRINT Hospitals
DATA:"<<endl;

cout <<"HospitalName"
<<"Location"

<<"Beds_Available"
<<"Rating"

<<"Hospital_Contact"
<<"Doctor_Name"

<<"Price_Per_Bed\n";

for (int i = 0; i < 4;
i++) {
cout
<< hospitals. H_name
<<"
"
<<"
"

<<"Hospitals.location"
<<"
"

<<"Hospitals.available_beds"
<<"

"

<<"Hospitals.rating"
<<"
"

<<"Hospitals.contact"
<<"
"

<<"Hospitals.doctor_name"
<<"
"

<<"Hospitals.price"
<<"
"

<<endl;

}
cout << endl

<<endl;
}
//Function to print patient and data for the hospital
void PrintPatientData(vector<Patient>& patients,
vector<Hospital>& hospitals)
{
cout<<"Print patients
Data:"<<endl;
cout<<"Patient_Name"
<<"Patient_Id"
<<"Patient_Contact"
<<"Alloted_Hospital"
<<"Patient_Expenditure\n";

for (int i = 0; i < 4; i++){
cout <<
patients.P_name
<<"

"
<<"

"

<<"patients.P_id"
<<"
"
<<"
"

<<"patients.contact"
<<"

"

<<"hospitals[i].H_name"
<<"

"

<<"patients[i].price"
<<"

"

<<endl;
}
cout <<endl
<<endl;
}
//Comparator function to sort the hospital data by name
bool name(Hospital& A, Hospital& B)
{
return A.H_name > B.H_name;
}
void SortHospitalByName(vector<Hospital> hospitals)
{
//sort the date
sort(hospitals.begin(), hospitals.end(),
name);

cout<<"SORT BY NAME:"
<<endl
<<endl;
PrintHospitalData(hospitals);
}
//Comparator function to sort the hospital data by rating
bool rating(Hospital& A, Hospital& B)
{
return A.rating > B.rating;
}
//Function to sort the hospital by namerating
void SortHospitalByRating(vector<Hospital> hospitals)
{
sort(hospitals.begin(), hospitals.end(),
rating);
cout<<"SORT BY Rating:"
<<endl
<<endl;

PrintHospitalData(hospitals);
}
//Comparator function to sort the hospital data by Bed
Avaialbility
bool beds(Hospital& A, Hospital& B)
{
return A.available_beds >
B.available_beds;
}
void SortbyBedsAvailable(vector<Hospital> hospitals)
{
sort(hospitals.begin(), hospitals.end(),
beds);

cout <<"SORT BY Available Beds:"
<<endl
<<endl;

PrintHospitalData(hospitals);
}
//Comparator function to sort the hospital data by Bed
price
bool beds_price(Hospital& A, Hospital& B)
{
return A.price < B.price;
}
void SortByBedsPrice(vector<Hospital> hospitals)
{
sort(hospitals.begin(), hospitals.end(),
beds_price);

cout<<"SORT BY Available Beds
Price:"
<<endl
<<endl;
}
//Comparator function to sort the hospital data by City
void PrintHospitalBycity(string city, vector<Hospital>
hospitals)
{
cout"PRINT hospitals by Name:"
<<city <<endl;

cout <<"HospitalName"

<<"Beds_Available"
<<"Rating"

<<"Hospital_Contact"
<<"Doctor_Name"

<<"Price_Per_Bed\n";

for (int i = 0; i < 4;
i++)
{

if(hospitals[i].location != city)

continue;

cout<<hospitals[i].H_name
<<"
"
<<"
"

<<"Hospitals[i].location"
<<"
"

<<"Hospitals[i].available_beds"
<<"

"

<<"Hospitals[i].rating"
<<"
"

<<"Hospitals[i].contact"
<<"
"

<<"Hospitals[i].doctor_name"
<<"
"

<<"Hospitals[i].price"
<<"
"

<<endl;
}
cout<< endl
<<endl;
}
//Function to implement Hospital Management System
void HospitalManagement(string patient_Name, int patient_Id[],
string patient_Contact[], int bookingCost[], string
hospital_Name[], string locations[], int beds[], float ratings[],
string hospital_Contact[], string doctor_Name[], int prices[]
)
{
vector<Hospital> hospitals;

//Create objects for hospital and the
users
Hospital h;

//Initailaize the data
for (int i = 0; i < 4; i++)
{
h.H_name =
hospital_Name[i];
h.location =
locations[i];
h.available_beds =
beds[i];
h.rating = ratings[i];
h.price = prices[i];
hospitals.push_back(h);
}

//Storing the patients data
vector<Patient> patients; Patient p;

//Initalize the data
for (int i = 0; i < 4; i++)
{
p.P_name =
patient_Name[i];
p.P_id = patient_Id[i];
p.contact =
patient_Contact[i];
p.price =
bookingCost[i];
patients.push_back(p);
}
cout <<endl;

//Calling the various operations
PrintHospitalData(hospitals);
PrintPatientData(patients, hospitals);

SortHospitalByName(hospitals);
SortHospitalByName(hospitals);
PrintHospitalBycity("Bangalore",
hospitals);
SortHospitalByName(hospitals);
SortHospitalByName(hospitals);
}
{
int main()
string patient_Name[] = {"P!", "P2", "P3", "P4"};
int patient_Id[] = {2, 3. 4, 1};
string patient_Contact[] = {"234534XXX7", "234576XXX2",
"857465XXX9", "567657XXX0"};
into bookingCost[] = {1000, 1200, 1100, 600};
string hospital_Name[] = {"H1", "H2", "H4", "H3"};
string locations[] = {"Bangalore", "Bangalore", "Mumbai",
"Prayagraj"};
int beds[] = {4, 5, 6, 9};
float ratings[] = {5.2,4., 3.4, 5.9};
string hospital_Contact[] = {"657534XXX7", "298766XXX2",
"324565XXX9", "343456XXX4"};
string doctor_Name[] = {"D1", "D4", "D3", "D2"};
int prices [] = {00, 200, 100, 290 };
HospitalMangement(patient_Name, patient_Id, patient_Contact,
bookingCost, hospital_Name, locations, beds, ratings,
hospital_Contact, doctor_Name, prices);
return 0;
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply