Answer to Question #206505 in C++ for Ali

Question #206505

Write a C++ Program ,

Create a typedef structure called Doctor that includes medical license (strin g), name of the doctor (string), channeling fee (float) and the number of pa tients checked during the week (int array)


Write a function called getData( ) which is the data type of Doctor that reads the details of Doctor and store them in the variable of the Doctor typedef structure


Hint Use the given function prototype as

Doctor geData (Doctor d);


Write a function called calDocFee( ) which takes three parameters, channel fee of the doctor, number of patients channeled in a week (7 days) array and the size of the array. Find the total charges for channeling of the doctor and print the total channeling fee


Call the getData( ) and calDocFee( ) functions in the main function to print the following output as required

Output

Enter medical license : PH-1234

Enter the name of the doctor :saye

Enter the channeling fee:1500

Enter the number of patient-Day 1:3

Total channeling fee: 63000


1
Expert's answer
2021-06-13T10:24:13-0400
#include<iostream>
#include<string>
using namespace std;


typedef struct Doctor  { 
	string includesMedicalLicense;
	string name;
	float channelingFee;
	int numberPatients[7];
} Doctor;
Doctor getData(Doctor d);
void calDocFee(float channelFee,int numberPatients[],int size);
int main(){
	Doctor doctor;
	doctor=getData(doctor);
	calDocFee(doctor.channelingFee,doctor.numberPatients,7);
	return 0; 
}
Doctor getData(Doctor d){
	cout<<"Enter the medical license of the doctor: ";
	getline(cin,d.includesMedicalLicense);
	cout<<"Enter the name of the doctor: ";
	getline(cin,d.name);
	cout<<"Enter the channeling fee of the doctor: ";
	cin>>d.channelingFee;
	for(int day=0;day<7;day++){
		cout<<"Enter the number of patients checked during the day "<<(day+1)<<": ";
		cin>>d.numberPatients[day];
	}
	return d;
}
void calDocFee(float channelFee,int numberPatients[],int size){
	float totalCharges=0;
	for(int day=0;day<size;day++){
		totalCharges+=numberPatients[day];
	}
	totalCharges=totalCharges*channelFee;
	cout<<"\nThe total charges for channeling of the doctor: "<<totalCharges<<"\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog