// Written by CENU
// cenu00@gmail.com
// FREEWARE!

#include <iostream>

int l = 0;
char i;

float a;
float b;
float c;

char g;

void add()
{
	std::cout << "\n>>Addition" << std::endl;
	std::cout << "  ";
	std::cin >> a;
	std::cout << " +";
	std::cin >> b;
	std::cout << "/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
	c = a + b;
	std::cout << "  " << c;
	std::cout << "\n>>Run another operation [y/n]?: ";
	std::cin >> g;
	if(g == 'y')
		return;
	else if(g == 'n')
	{
		l++;
		return;
	}
	else
	{
		std::cout << "\n>>Interpretting vague answer as \'yes\'." << std::endl;
		return;
	}
}

void sub()
{
	std::cout << "\n>>Subtraction" << std::endl;
	std::cout << "  ";
	std::cin >> a;
	std::cout << " -";
	std::cin >> b;
	std::cout << "/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
	c = a - b;
	std::cout << "  " << c;
	std::cout << "\n>>Run another operation? [y/n]: ";
	std::cin >> g;
	if(g == 'y')
		return;
	else if(g == 'n')
	{
		l++;
		return;
	}
	else
	{
		std::cout << "\n>>Interpretting vague answer as \'yes\'." << std::endl;
		return;
	}
}

void mul()
{
	std::cout << "\n>>Multiplication" << std::endl;
	std::cout << "  ";
	std::cin >> a;
	std::cout << " *";
	std::cin >> b;
	std::cout << "/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
	c = a * b;
	std::cout << "  " << c;
	std::cout << "\n>>Run another operation [y/n]?: ";
	std::cin >> g;
	if(g == 'y')
		return;
	else if(g == 'n')
	{
		l++;
		return;
	}
	else
	{
		std::cout << "\n>>Interpretting vague answer as \'yes\'." << std::endl;
		return;
	}
}

void div()
{
	std::cout << "\n>>Division" << std::endl;
	std::cout << "  ";
	std::cin >> a;
	std::cout << "----------------\n  ";
	std::cin >> b;
	std::cout << "/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
	c = a / b;
	std::cout << "  " << c;
	std::cout << "\n>>Run another operation [y/n]?: ";
	std::cin >> g;
	if(g == 'y')
		return;
	else if(g == 'n')
	{
		l++;
		return;
	}
	else
	{
		std::cout << "\n>>Interpretting vague answer as \'yes\'." << std::endl;
		return;
	}
}

void XOR()
{
	int x;
	int y;
	int z;

	std::cout << "\n>>XOR" << std::endl;
	std::cout << "  ";
	std::cin >> x;
	std::cout << " ^";
	std::cin >> y;
	std::cout << "/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
	z = x ^ y;
	std::cout << "  " << z;
	std::cout << "\n>>Run another operation [y/n]?: ";
	std::cin >> g;
	if(g == 'y')
		return;
	else if(g == 'n')
	{
		l++;
		return;
	}
	else
	{
		std::cout << "\n>>Interpretting vague answer as \'yes\'." << std::endl;
		return;
	}
}

int main()
{
	std::cout << "\n>>CENU'S CALCULATOR PROGRAM (FREEWARE!)\n>>Written by CENU\n>>cenu00@gmail.com" << std::endl;
	
	while(l == 0)
	{
		std::cout << "\n>>Which operation would you like to run?\n" << std::endl;
		std::cout << "a - Addition\ns - Subtraction\nm - Multiplication\nd - Division\nx - XOR\nq - Quit\n" << std::endl;
		std::cin >> i;

		if(i == 'a')
			add();
		else if(i == 's')
			sub();

		else if(i == 'm')
			mul();

		else if(i == 'd')
			div();

		else if(i == 'x')
			XOR();

		else if(i == 'q')
			l++;
		else
			std::cout << "\nEntry not recognized." << std::endl;
	}
	std::cout << "\n";
	return 0;
}
