Integrity Statement: Read carefully! Strict directives have been given to the as
ID: 3680858 • Letter: I
Question
Integrity Statement: Read carefully!
Strict directives have been given to the assistants who will be marking this homework as a departmental policy is being developed on cheating. Any student caught in any form of cheating will be given zero (0) the first time. (We will not get into the issue of who copied from whom!!!). If such an act reoccurs, the case will be sent to the Student Discipline Committee.
Submit this cover page with your assignment and sign here that you have read and understood this "Integrity Statement" paragraph.
Define the struct Medicine with the components medicineName, type (of type string) and the components dosage, cost (of type double).
Define the class Illness with private data members illnessName (of type string), numberOfMedicines (of type int), totalMedicationCost (of type double which is the total cost of all medicines), and medication (an array of type Medicine). The class also has the member functions set(string, int), print(), getNumberOfMedicines(), getMedicationCost(), getIllnessName(), calculateCost(), a constructor with parameters, and a default constructor.
Define the class Person with private data members personName, insurance (of type string), age (of type int). The class also has the member functions set(string, string, int), print(),and a default parameterized constructor.
Define the class Patient which publicly inherits the class Person and has the private data members hospitalID (of type string), duration, numberOfSicknesses (of type int), treatmentCost (of type double which is the total cost of all sicknesses plus the admission fees and the room fees), and sicknesses (an array of type Illness). The class also has the member functions calculateCost(), set(string, string, int, string, int, int), print(), and a default parameterized constructor. The hospital admission fees is 500 dirham and the room fees is 600 dirham per day.
Implement all member functions.
Use the following main program:
int main()
{
Patient p1("Hassan Mohsen", "B3A27K", 52, "H2P003", 5, 2);
p1.print();
return 0;
}
Sample input / output:
Explanation / Answer
#include <iostream.h> // input output stream header file
#include <stdio.h> // standard input output header file
#include <stdlib.h> // standard library header file
#include <string.h> // header file with string function
#include <conio.h> // console input output header file
struct medicineTag {
char medicineName[30];
char type[20];
double dosage, cost;
} ;
struct medicineTag Medicine[100];
class Illness {
private:
// data members
char illnessName[60];
int numberOfMedicines;
double totalMedicationCost;
struct medicineTag medication[100];
public:
// member functions
Illness(); // default constructor
Illness(char illName[60], int numMed, double totCost ) {
strcpy(illnessName, illName);
numberOfMedicines = numMed;
totalMedicationCost = totCost;
}
void set(char atr1[30], int i) {
}
void print() {
cout << " Illness Name" << illnessName;
cout << " number of Medicines prescribed: " << numberOfMedicines;
cout << " Total cost of all medications: " << totalMedicationCost;
cout << " Wishing you get well soon ..........";
}
int getNumberOfMedicines() {
int num;
return num;
}
double getMedicineCost() {
double cost;
return cost;
}
char * getIllnessName() {
char *illnessName;
return illnessName;
}
void calculateCost() {
}
}; // end class illness
class Person { // base class
private:
char personName[60];
char insurance[20];
int age;
public:
// default constructor
Person();
// parameterized constructor
Person(char s1[60], char s2[20], int ag) {
strcpy( personName, s1);
strcpy(insurance, s2);
age = ag;
}
// member functions
char * getName() { return personName;}
char * getInsur() { return insurance;}
int getAge() { return age; }
void setName(char s1[60]) {
strcpy( personName, s1);
}
void setInsur(char s2[20]) {
strcpy(insurance, s2);
}
void setAge(int ag) {
age = ag;
}
set(char s1[60], char s2[20], int ag) {
strcpy( personName, s1);
strcpy(insurance, s2);
age = ag;
}
void print() {
cout << " Person Name: " << personName;
cout << " Insurance Number: " << insurance << " Age: " << age;
}
} ; // end class person
class Patient : public Person { // inherit publicly
private:
char hospitalID[20];
char duration[20];
int numberOfSicknesses;
double treatmentCost;
//illness sicknesses[40];
//illness sicknesses;
// an array of objects of type class illness
public:
// default constructor
Patient();
// parametrized constructor
Patient(char patntName[60], char ins[20], int ag, char hid[20], int dur, int numOfSkns) {
base::setName(patntName);
//strcpy( personName, patntName);
//strcpy( insurance, ins);
//age = ag;
strcpy(hospitalID, hid);
strcpy(duration, dur);
numberOfSicknesses = numOfSkns;
}
// member functions
void calculateCost() {
}
//set(string, string, int, string, int, int),
//Patient p1("Hassan Mohsen", "B3A27K", 52, "H2P003", 5, 2);
setPatient(char patntName[60], char ins[20], int ag, char hid[20], int dur, int numOfSkns) {
strcpy( personName, patntName);
strcpy( insurance, ins);
age = ag;
strcpy(hospitalID, hid);
strcpy(duration, dur);
numberOfSicknesses = numOfSkns;
}
// member functions
set(char patntName[60], char ins[20], int ag, char hid[20], int dur, int numOfSkns) {
strcpy( personName, patntName);
strcpy( insurance, ins);
age = ag;
strcpy(hospitalID, hid);
strcpy(duration, dur);
numberOfSicknesses = numOfSkns;
}
} ; // end class patient
int main() // start main
{
return 0; // exit
} // end of main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.