Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

oo T-Mobile 11:24 AM Done JavalC++ IF Assignment 3-100 points Due date- Sept 24

ID: 3888442 • Letter: O

Question

oo T-Mobile 11:24 AM Done JavalC++ IF Assignment 3-100 points Due date- Sept 24 You are to write a program to do the following: (input data of your choice Read in the number patients having knee surgery Read in the total fees charged to those patients . . Read in the name of the Doctor doing the knee surgeries . Read in the number patients having hip surgery . Read in the total fees charged to those patients Read in the name of the Doctor doing the hip surgeries Read in the number patients having heart surgery Read in the total fees charged to those patients Read in the name of the Doctor doing the heart surgeries . . . Print all of the data read in Calculate and print the total fees paid Calculate and print the average of all fees paid Print the type of surgery that had the highest fees paid Print the Doctor who had the highest fees Print the Doctor who did the highest amount of surgeries * . . . Copy the source code to word. Copy a screen shot of the final output to the same word document Upload the document to blackboard .

Explanation / Answer

c++ code:

#include<bits/stdc++.h>
using namespace std;

int maxxfees(double fees1,double fees2,double fees3 )
{
if(fees1 >= fees2)
{
  if(fees1 >= fees3)
  {
   return 1;
  }
  else
  {
   return 3;
  }
}
else
{
  if(fees2 >= fees3)
  {
   return 2;
  }
  else
  {
   return 3;
  }
}
}

int maxxsurgeries(double s1,double s2,double s3 )
{
if(s1 >= s2)
{
  if(s1 >= s3)
  {
   return 1;
  }
  else
  {
   return 3;
  }
}
else
{
  if(s2 >= s3)
  {
   return 2;
  }
  else
  {
   return 3;
  }
}
}

int main()
{
//take input
string tmp;
int n_patients_knee; //Number of patients with knee enjury
double total_fees_knee;
string doctor_name_knee;
cout << "Enter Number of patients with knee enjury ";
getline(cin , tmp);
n_patients_knee = atoi(tmp.c_str());
cout << "Enter Total fees for those patients ";
getline(cin , tmp);
total_fees_knee = atof(tmp.c_str());
cout << "Enter name of the doctor who did knee surgery ";
getline(cin , doctor_name_knee);

int n_patients_hip; //Number of pateints with hip enjury
double total_fees_hip;
string doctor_name_hip;
cout << "Enter Number of patients with hip enjury ";
getline(cin , tmp);
n_patients_hip = atoi(tmp.c_str());
cout << "Enter Total fees for those patients ";
getline(cin , tmp);
total_fees_hip = atof(tmp.c_str());
cout << "Enter name of the doctor who did hip surgery ";
getline(cin , doctor_name_hip);

int n_patients_heart; //Number of pateints with heart surgery
double total_fees_heart;
string doctor_name_heart;
cout << "Enter Number of patients with heart surgery ";
getline(cin , tmp);
n_patients_heart = atoi(tmp.c_str());
cout << "Enter Total fees for those patients ";
getline(cin , tmp);
total_fees_heart = atof(tmp.c_str());
cout << "Enter name of the doctor who did heart surgery ";
getline(cin , doctor_name_heart);

// print output
cout << " -----Data for knee enjury----- ";
cout << "Number of patients: " << n_patients_knee << endl;
cout << "Total fees for patients: " << total_fees_knee << endl;
cout << "Name of the doctor: " << doctor_name_knee << endl;

cout << " -----Data for hip enjury----- ";
cout << "Number of patients: " << n_patients_hip << endl;
cout << "Total fees for patients: " << total_fees_hip << endl;
cout << "Name of the doctor: " << doctor_name_hip << endl;

cout << " -----Data for heart surgery----- ";
cout << "Number of patients: " << n_patients_heart << endl;
cout << "Total fees for patients: " << total_fees_heart << endl;
cout << "Name of the doctor: " << doctor_name_heart << endl;

cout << "Total fees for knee + hip + heart patients = " << total_fees_knee + total_fees_hip + total_fees_heart <<endl;
cout << "Average fees for knee , hip , heart patients = " << (total_fees_knee + total_fees_hip + total_fees_heart)/3 <<endl;

int highest_fees = maxxfees(total_fees_knee, total_fees_hip, total_fees_heart);
if(highest_fees == 1)
{
  cout << "Highest fees paid for knee surgery ";
  cout << "Highest fees paid to the doctor: " << doctor_name_knee << endl;
}
else if(highest_fees == 2)
{
  cout << "Highest fees paid for hip surgery ";
  cout << "Highest fees paid to the doctor: " << doctor_name_hip << endl;
}
else
{
  cout << "Highest fees paid for heart surgery ";
  cout << "Highest fees paid to the doctor: " << doctor_name_heart << endl;
}


int highest_surgaries = maxxsurgeries(n_patients_knee, n_patients_hip,n_patients_heart);
if(highest_surgaries == 1)
{
  cout << "Highest surgeries made by the doctor: " << doctor_name_knee << endl;
}
else if(highest_surgaries == 2)
{
  cout << "Highest surgeries made by the doctor: " << doctor_name_hip << endl;
}
else
{
  cout << "Highest surgeries made by the doctor: " << doctor_name_heart << endl;
}

return 0;
}

Sample Output:

Enter Number of patients with knee enjury
100
Enter Total fees for those patients
1000
Enter name of the doctor who did knee surgery
doctor1
Enter Number of patients with hip enjury
200
Enter Total fees for those patients
2000
Enter name of the doctor who did hip surgery
doctor2
Enter Number of patients with heart surgery
300
Enter Total fees for those patients
3000
Enter name of the doctor who did heart surgery
doctor3


-----Data for knee enjury-----
Number of patients: 100
Total fees for patients: 1000
Name of the doctor: doctor1


-----Data for hip enjury-----
Number of patients: 200
Total fees for patients: 2000
Name of the doctor: doctor2


-----Data for heart surgery-----
Number of patients: 300
Total fees for patients: 3000
Name of the doctor: doctor3
Total fees for knee + hip + heart patients = 6000
Average fees for knee , hip , heart patients = 2000
Highest fees paid for heart surgery
Highest fees paid to the doctor: doctor3
Highest surgeries made by the doctor: doctor3