EEE2109 Final Fall2020 v2
EEE2109 Final Fall2020 v2
PART A
a Tent University is holding a fundraiser. The freshmen, sophomores, juniors, and seniors hold a [6.5]
competition to see which class contributes the most money. Apply a C++ program that allows
you to enter two numbers for each contribution as it comes in — the class of the contributor (1,
2, 3, or 4), and the amount contributed in dollars.
For example, perhaps a junior contributes $20. The user would enter a 3 and a 20. The program
continues to accept data until the user types a wrong class for the contributor’s class. At that
point, data entry is completed, so display the four class totals as well as the number of the class
(1, 2, 3, or 4) that contributed the most.
b Show a C++ program to check the divisibility of an integer by 11. Your program must make [6]
use of the fact that an integer is divisible by 11 if and only if the difference of the sum of odd
digits and the sum of even digits is divisible by 11. You must use this fact repeatedly, till the
sum reduces to a single digit. For example, 123456789 is divisible by 11 if and only if (1 + 3 +
5 + 7 + 9) − (2 + 4 + 6 + 8) = 25 − 20 = 5 is divisible by 11. Now, 5 is a single digit other than
0 and therefore the program concludes that 123456789 is not divisible by 11.
a Create a digital dice with six values 1, 2, 3, 4, 5, and 6. A dice is said to be fair if no face turns [6.5]
up more than 10% of any other face. Apply a C++ program to check whether or not your digital
dice is fair. To implement this concept, design your program so that there is a class Dice that
has a method roll() and a class Experiment that has a method isFair(). There is a third
class Program that allows you to input the number of rolls you would like to perform before
you test the fairness.
Page 1 of 5
b Show a C++ program that prompts the user to input a digit. The program should then output a [6]
square of that size using the digit as shown in the examples.
Example 1: Example 2:
If the input is 5, then the output is If the input is 6, then the output is
55555 666666
53335 644446
53135 642246
53335 642246
55555 666666
a Apply a C++ class named WeatherReport that holds a daily weather report with data members [6.5]
such as dayOfMonth, highTemp, lowTemp, amountRain, and amountSnow.
The constructor initializes the fields with default values: 31 for dayOfMonth, 100 for
highTemp, -100 for lowTemp, and 0 for amountRain and amountSnow.
Include a function that prompts the user and sets values for each field so that you can
override the default values.
Instantiate 30 WeatherReport objects and, in a loop, prompt the user for a month’s
data. You can use either vector / array and class/structure to store several fields of
weather reports.
At the end of the month, a month-end WeatherReport object is created. Initialize the
object with default values;
Then use a friend function to store the high temperature, low temperature, and rain and
snow totals for the month in the object. The friend function takes two WeatherReport
objects—the summary object and one day’s object—and it returns an updated summary
object. If the day’s high temperature is higher than the summary object’s high, then
replace the summary high. If the day’s low temperature is lower than the summary
object’s low, then replace the summary low. Accumulate rain and snow in the summary
object. Write a main()function that creates a month-end weather report from the 30
daily reports.
b Show and apply a function in C++ that can convert a string to corresponding telephone number. [6]
If it is an uppercase letter or a lower case letter, the program will substitute it with the
corresponding digit. If it is already a digit, no substitution is done. Thus, “GOODCAR”,
“gooDCar”, and “go6DC2r” will be translated to 4663227.
Number Letter Number Letter Number Letter
0 none 4 GHI 8 TUV
Page 2 of 5
1 none 5 JKL 9 WXYZ
2 ABC 6 MNO
3 DEF 7 PQRS
PART B
The answer script (one single pdf file) of this part (Part B) must be uploaded at designated location in
the provided google form link available in the google classroom.
Describe and write a C++ program to computerize the billing system of a clinic with the following [12.5]
design criterion.
a. Design the class person, which has the following attributes: firstName: string ,
lastName: string, and following attributes :void print(), void
setName(string, string) , string getFirstName() const, string
getLastName() const and person(string = "", string = "")
b. Design the class doctor, inherited from the class person, with an additional data member
to store a doctor’s specialty. Add appropriate constructors and member functions to
initialize, access, and manipulate the data members.
c. b. Design the class bill with data members to store a patient’s ID and a patient’s clinic
charges, such as pharmacy charges for medicine, doctor’s fee, and room charges. Add
appropriate constructors and member functions to initialize, access, and manipulate the
data members.
d. Design the class patient, inherited from the class person with additional data members to
store a patient’s ID, age, date of birth, attending physician’s name, the date when the
patient was admitted in the hospital, and the date when the patient was discharged from
the hospital. (Use the class date to store the date of birth, admit date, discharge date, and
the class doctor to store the attending physician’s name.) Add appropriate constructors
and member functions to initialize, access, and manipulate the data members.
Your program must test all these classes.
The equation of a line in standard form is ax + by = c, wherein both a and b cannot be zero, and a, [12.5]
Page 3 of 5
b, and c are real numbers. If c= 0, then –a/b is the slope of the line. If a = 0, then it is a horizontal
line, and if b = 0, then it is a vertical line. The slope of a vertical line is undefined. Two lines are
parallel if they have the same slope or both are vertical lines. Two lines are perpendicular if either
one of the lines is horizontal and the other is vertical or the product of their slopes is –1. Develop
the class lineType to store a line. To store a line, you need to store the values of a (coefficient of
x), b (coefficient of y), and c. Your class must contain the following operations:
Using classes of C++, develop an online address book to keep track of the names, addresses, phone [12.5]
numbers, and dates of birth of family members, close friends, and certain business associates. Your
program should be able to handle a maximum of 500 entries.
a. Analyze a class addressType that can store a street address, city, state,and ZIP code. Use the
appropriate functions to print and store the address. Also, use constructors to automatically
initialize the member variables.
b. Analyze a class extPersonType using the class personType, the class dateType, and the
class addressType. Add a member variable to this class to classify the person as a family
member, friend, or business associate. Also, add a member variable to store the phone number.
Add (or override) the functions to print and store the appropriate information. Use constructors to
Page 4 of 5
automatically initialize the member variables.
personType dateType
-firstName: string –dMonth: int
-lastName: string –dDay: int
–dYear: int
+print(): void +setDate(int, int, int): void
+setName(string, string): void +getDay() const: int
+getFirstName() const: string +getMonth() const: int
+getLastName() const: string +getYear() const: int
+personType(string="", string +printDate() const: void
= "") +dateType(int=1, int=1, int=1900)
c. Analyze the class addressBookType using the previously defined classes. An object of the
type addressBookType should be able to process a maximum of 500 entries. The program should
perform the following operations:
i. Load the data into the address book from a disk.
ii. Sort the address book by last name.
iii. Search for a person by last name.
iv. Print the address, phone number, and date of birth (if it exists) of a given person.
v. Print the names of the people whose birthdays are in a given month.
vi. Print the names of all the people between two last names.
vii. Depending on the user’s request, print the names of all family members, friends, or business
associates.
Page 5 of 5