Please, submit your homework electronically using the "submit" system.
Please try to follow the "good programming" conventions
we discussed in class. Write modular code and include all
of your functions in the same CPP file as your main.
(HW_4_1.cpp/exe) Write a program which prompts
the user to enter a list of objects of the same type (for this
excercise we only consider int, char and double types).
Then define 2 function templates for a subroutine named
min_max, which
has an (abstract type) array parameter, an int for the
size of the array and call-by-reference for the min and
max of the array. And a subroutine report,
which is also a function template and has two call-by-reference
parameters for the min and max, which it reports
to the standard output. [Of course, you'd need 3 separate functions
for collecting the user input for these three data types.]
Sample Run:
%> This program computes and reports the minimum and
the maximum for any array of type containing an
overload for the "<" operator:
%> How many integers do you have?
%> 4
%> Enter the list of 4 integers! We'll report the min/max values!
%> 1
%> -44
%> 50
%> -17
%> Your minimum is: -44. Your maximum is: 50.
%> Enter the list of 4 characters! We'll report the min/max values!
%> 1
%> A
%> a
%> &
%> Your minimum is: &. Your maximum is: a.
%> Enter the list of 4 doubles! We'll report the min/max values!
%> 1.3
%> -17.4
%> 101
%> 56.4555
%> Your minimum is: -17.4. Your maximum is: 101.
%> Would you like to try another run (Y/N)?
%> N
%> Bye!
\Ivo D. Dinov, Ph.D., Department of Neurology
and Program in Computing, UCLA School of Medicine/