Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.10.80
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/bafreeman/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bafreeman/template1.cpp
#include <iostream>
using namespace std;

template <class T>
T GetMax (T a, T b);

void menu();
template<class T>
void process();

int main()
{
	string a, b, c;
	char ch;
	menu();
	cin >> ch;

	while (tolower(ch) != 'q')
	{
		switch(tolower(ch))
		{
			case 'i':	
				cout << "\tInput two integers: ";
				process<int>();
				break;
			 case 'f':
                                cout << "\tInput two floating numbers: ";
                                process<float>();
                                break;
			case 'c':
                                cout << "\tInput two characters: ";
                                process<char>();
                                break;
			 case 's':
                                cout << "\tInput two words: ";
                                process<string>();
                                break;
			 case 'x':
                                cout << "\tInput the one full name: ";
                                cin.ignore();
				//string a, b, c;
				getline(cin, a);
                                cout << "\tInput the second full name: ";
                                getline(cin, b);
				c = GetMax<string> (a, b);
			        cout << "\n\n\tThe bigger one is: " << c << "\n\n";
				break;
			default:
				cout << "\nInvalid, redo it\n";
		}
		menu();
		cin >> ch;
	}
	cout << "\n\nDone.\n";
	return 0;
}

//--------------------------------
template<class T>
void process()
{
	T a, b, c;
        cin >> a >> b;
        c = GetMax (a, b);
        cout << "\n\n\tThe bigger one is: " << c << "\n\n";
}
//--------------------------------
template <class T>
T GetMax (T a, T b)
{
	T result;
	if(a > b)
		result = a;
	return (result);
}

//---------------------------------

void menu()
{
	cout << "\n\n\t--- Welcome to the bigger game! ---\n";
	cout << "\t    =============================\n\n";
	cout << "\tI	Integers\n";
	cout << "\tF	Floating\n";
	cout << "\tC	Characters\n";
	cout << "\tS	Single Strings\n";
	cout << "\tX	General Strings\n";
	cout << "\tQ	Quit\n";
	cout << "\t------------------------\n";
	cout << "\n\tYour choice: ";
}

Stv3n404 - 2023