oo T-Mobile 11:24 AM Done JavalC++ IF Assignment 3-100 points Due date- Sept 24
ID: 3888441 • 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
Given below is the program for the question with output.
If it helped, please do rate the answer . Thank you very much.
#include <iostream>
using namespace std;
int main()
{
//total fees for knee, hip and hear surgeries respectively
double kneeFeeTotal, hipFeeTotal, heartFeeTotal;
int kneePatients, hipPatients, heartPatients;
string kneeDoctor, hipDoctor, heartDoctor;
cout << "Enter the details of surgery - " << endl << endl;
//get details for knee surgery
cout << "Knee surgery: " << endl;
cout << "No. of patients having knee surgery: ";
cin >> kneePatients;
cout << "Total fees for those patients: ";
cin >> kneeFeeTotal;
cout << "Doctor doing knee surgery: ";
cin.ignore();//ignore newline
getline(cin, kneeDoctor);
cout << endl << endl;
//get details for hip surgery
cout << "Hip surgery: " << endl;
cout << "No. of patients having hip surgery: ";
cin >> hipPatients;
cout << "Total fees for those patients: ";
cin >> hipFeeTotal;
cout << "Doctor doing hip surgery: ";
cin.ignore();//ignore newline
getline(cin, hipDoctor);
cout << endl << endl;
//get details for heart surgery
cout << "Heart surgery: " << endl;
cout << "No. of patients having heart surgery: ";
cin >> heartPatients;
cout << "Total fees for those patients: ";
cin >> heartFeeTotal;
cout << "Doctor doing heart surgery: ";
cin.ignore();//ignore newline
getline(cin, heartDoctor);
//display all data
cout << " Surgery No. Patients Total Fees Doctor" << endl;
cout << "Knee " << kneePatients << " $" << kneeFeeTotal << " " << kneeDoctor << endl;
cout << "Hip " << hipPatients << " $" << hipFeeTotal << " " << hipDoctor << endl;
cout << "Heart " << heartPatients << " $" << heartFeeTotal << " " << heartDoctor << endl << endl;
//calculate total and average fee
double totalFee = kneeFeeTotal + hipFeeTotal + heartFeeTotal;
double totalPatients = kneePatients + hipPatients + heartPatients;
double averageFee = totalFee / totalPatients;
cout << "Total fees: $" << totalFee << endl;
cout << "Average fees: $" << averageFee << endl <<endl;
//find the highest paid doctor and surgery type
double highestFee;
string highestPaidDoc, highestFeeSurgery;
if(kneeFeeTotal > hipFeeTotal)
{
if(kneeFeeTotal > heartFeeTotal)
{
highestFee = kneeFeeTotal;
highestPaidDoc = kneeDoctor;
highestFeeSurgery = "Knee Surgery";
}
else
{
highestFee = heartFeeTotal;
highestPaidDoc = heartDoctor;
highestFeeSurgery = "Heart Surgery";
}
}
else
{
if(hipFeeTotal > heartFeeTotal)
{
highestFee = hipFeeTotal;
highestPaidDoc = hipDoctor;
highestFeeSurgery = "Hip Surgery";
}
else
{
highestFee = heartFeeTotal;
highestPaidDoc = heartDoctor;
highestFeeSurgery = "Heart Surgery";
}
}
cout << "Highest fee Surgery: " << highestFeeSurgery << endl;
cout << "Doctor with highest fees: " << highestPaidDoc << endl << endl;
//find out the doctor who did highest no. of surgeries
string maxSurgeryDoc;
//compare hte no. of patients in each of the surgery types
if(kneePatients > hipPatients)
{
if(kneePatients > heartPatients)
maxSurgeryDoc = kneeDoctor;
else
maxSurgeryDoc = heartDoctor;
}
else
{
if(hipPatients > heartPatients)
maxSurgeryDoc = hipDoctor;
else
maxSurgeryDoc = heartDoctor;
}
cout << "Doctor who did highest no. of surgeries is : " << maxSurgeryDoc << endl;
}
output
Enter the details of surgery -
Knee surgery:
No. of patients having knee surgery: 100
Total fees for those patients: 25000
Doctor doing knee surgery: Michael J
Hip surgery:
No. of patients having hip surgery: 50
Total fees for those patients: 5000
Doctor doing hip surgery: Robert W
Heart surgery:
No. of patients having heart surgery: 200
Total fees for those patients: 15000
Doctor doing heart surgery: John Smith
Surgery No. Patients Total Fees Doctor
Knee 100 $25000 Michael J
Hip 50 $5000 Robert W
Heart 200 $15000 John Smith
Total fees: $45000
Average fees: $128.571
Highest fee Surgery: Knee Surgery
Doctor with highest fees: Michael J
Doctor who did highest no. of surgeries is : John Smith
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.