Write a C++ program to find the maximum of two values using a function template.   Include a method T maximumNumber(T a, T b) to return the maximum of two given numbers using the template.   In the main method, obtain the data type of numbers and get the numbers from the user.  Pass the numbers to the maximumNumber () method to find the maximum number

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question
100%
QUESTION OUTPUT AND YOUR OUTPUT MUST MATCH 
---------------------------------
 
There is a recreational activity going on in Ashu's colony on Children's Day. It is a race where participants are supposed to collect water in a bowl from one end and pour it into a vessel in another. The race time is fixed, the one who fills more water in the vessel wins the race. You are Ashu and you were asked to design a program to find the winner. Since water quantity could be in decimals as well you decide to use a function template to store the values and find the maximum amongst the two.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

Write a C++ program to find the maximum of two values using a function template.
 
Include a method T maximumNumber(T a, T b) to return the maximum of two given numbers using the template.
 
In the main method, obtain the data type of numbers and get the numbers from the user.  Pass the numbers to the maximumNumber () method to find the maximum number.
 
Input and Output Format:
Refer sample input and output for formatting specifications.

[All text in bold corresponds to input and rest corresponds to output]
Sample Input and Output 1:
1.Integer                                                                                                       
2.Double                                                                                                        
Enter your choice                                                                                               
1                                                                                                               
Enter the first integer value                                                                                   
11                                                                                                              
Enter the second integer value                                                                                  
22                                                                                                              
The maximum number is 22  
 
Sample Input and Output 2:
1.Integer                                                                                                       
2.Double                                                                                                        
Enter your choice                                                                                               
                                                                                                              
Enter the first double value                                                                                    
22.15                                                                                                           
Enter the second double value                                                                                   
3.14                                                                                                            
The maximum number is 22.15
 
Sample Input and Output 3:
1.Integer                                                                                                       
2.Double                                                                                                        
Enter your choice                                                                                               
                                                                                                              
Invalid choice 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning