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 27PE
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr