NOTE: This can be done and compiled using visual studio or any other program, an
ID: 3536843 • Letter: N
Question
NOTE: This can be done and compiled using visual studio or any other program, any help appreciated and highly rated. The text is long but it is simple since you will understand it and draw the inheritance hierarchy (there is only 4 classes). Thank you in advance:)
Exercise 1
In addition to Science and Technology, health is also another major concern of the university of michigan.
The Faculty of Health Sciences at Michigan university decided to lunch a health clinic. The
clinic accepts patients 24 hours a day. You are asked to write a C++ software that keeps
track of all patients at the Health Sciences clinic. Patients visiting the clinic are classified
into two classes, outpatients and resident-patients. All patients are identified by a patient
id, patient name , date of admission, and every patient has a treating physician. The
treating physician himself is a class that is recognized by physician id and phone number .
Outpatients are those patients that are treated and leave the clinic on the same date of
admission, but they are assigned a check-back date so the physician can recheck on them
later on. Resident-patients are those patients that stay at hospital for several days, and
thus, they are assigned a bed ID, and the number of day-stay at clinic. All patients have to
pay the fees for the treatments they get. As for the outpatients they pay the basic
treatment charge plus the cost of medicine they had. However, resident patients should
pay the basic treatment charge plus $ 50 per night spent at the clinic.
Requirements:
a) Illustrate the above scenario with a diagram that shows the composition and
inheritance hierarchy among classes.
b) Using C++ language, implement all four classes you mentioned in part (a). For
each class you should write the following methods:
- A default constructor.
- The set and get methods for all data members.
- A utility method, print(), that prints all the data members in the class.
- A utility method, readInfo(), that reads the information from the user into
all data members in the class.
- A method that prints the treatment fees due.
Also, you are asked to write Friend functions for the base class that overload the
stream insertion (<<) and stream extraction (>>) operators. The stream insertion
(<<) function calls the print utility method, and the stream extraction method calls
the read utility method.
c) Further, you are asked to write a main C++ application that instantiate a dynamic
polymorphic array of %u201Cn%u201D patients. Then the program should do the following:
- Print information about all patients in the clinic to the screen.
- Print information (patientID , patientName , and fees Due) about all
patients in the clinic to a binary file named "patientRecords .dat". The
information should be written as one object at a time in the increasing
order according to patientID .
- Print the information about a specific patient.
- The number of patients visited the clinic.
- The total payments done by patients.
- The bed ID%u2019s that are assigned to resident patients.
- Read a patient ID from the user and searches if it is found in the file
"patientRecords .dat".
i. If the ID exists in the file, the program writes the patient%u2019s name and his corresponding fees due into a sequential file named: %u201CsearchedPatients.txt%u201D.
ii. If the ID is not found in the file, a new entry should be inserted into %u201CpatientsRecords.dat%u201D file in the correct place.
Exercise 2
Write the definition and implementation of the Academic_Book class defined as
follows:
Academic_Book
Attributes
%uF0B7 Code: a number to identify each book.
%uF0B7 Title: a string of characters.
%uF0B7 Level: to classify the book academic level(1 for "school",2
for "university").
%uF0B7 Issue_year: a number to indicate the book printing year.
Methods
%uF0B7 Cost: a double value to store the cost of a book.
%uF0B7 Constructor (default values)
%uF0B7 set and get methods.
%uF0B7 Calculate Price: return the book price calculated as
follow: the cost + tax of 5% t for level 1, and 7% for level 2
%uF0B7 write friend methods to overload the >> and << operators.
Write a C++ program that first creates the random access file Academic_Book.dat and
initializes it to 100 empty records. Then prompt the user to input data about N
Academic_Books and write them to the Book.dat file (the book Code should be the record number in the file).
The program should provide the user with the following menu to process the Book.dat file: (write a function to implement each task)
1. Write on the "books tittel.txt: sequential file an ascending sorted list of books title.
2. copy to the "high price.txt" sequential file the information about school books
with price > $40
3. increase the cost of each university book by 3%
4. add a new book to the file (input the new book data first; check if the bool exists
before you attempt to write the book informatuon)
5. delete a specific book from the file (input the book code; if the book doesn't exist
output an alert message)
6. exit.
Explanation / Answer
FOLLOW THIS
Much of the skill in writing unmaintainable code is the art of camouflage, hiding things, or making things appear to be what they are not. Many depend on the fact the compiler is more capable at making fine distinctions than either the human eye or the text editor. Here are some of the best camouflaging techniques.
struct snafu {
unsigned cNt
char* pTr;
size_t lEn;
} A;
Variables that resemble others except for capitalization and underlines have the advantage of confounding those who like remembering names by sound or letter-spelling, rather than by exact representations.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.