#include <iostream>
#include <string>
using namespace std;
int main()
{
int ages[100];
float fees[100];
int Id[100];
int totalPatients=0;
float totalIncome=0;
cout<<"Enter the number of patients: ";
cin>>totalPatients;
for(int i=0;i<totalPatients;i++){
cout<<"Enter age of the patient "<<(i+1)<<": ";
cin>>ages[i];
cout<<"Enter fees patients paid of the patient "<<(i+1)<<": ";
cin>>fees[i];
cout<<"Enter id of the patient "<<(i+1)<<": ";
cin>>Id[i];
cout<<"\n";
}
int youngestPatient=ages[0];
int oldestPatient=ages[0];
int youngestPatientIndex=0;
int oldestPatientIndex=0;
for(int i=0;i<totalPatients;i++){
if(youngestPatient>ages[i]){
youngestPatient=ages[i];
youngestPatientIndex=i;
}
if(oldestPatient<ages[i]){
oldestPatient=ages[i];
oldestPatientIndex=i;
}
totalIncome+=fees[i];
}
cout<<"\nYoungest patient with id "<<Id[youngestPatientIndex]<<" is "<<ages[youngestPatientIndex]<<" years old\n";
cout<<"Oldest patient with id "<<Id[oldestPatientIndex]<<" is "<<ages[oldestPatientIndex]<<" years old\n";
cout<<"\nTotal income: "<<totalIncome<<"\n";
cout<<"The total number of patients seen on the day: "<<totalPatients<<"\n";
cin>>totalPatients;
return 0;
}
Comments