SmileA bit advanced calculator :)

Posts 1–7 of 7 · Page 1 of 1
A bit advanced calculator :)
I was bored and made this... Here is the code

Code:
#include<iostream>
#include<cmath>

using namespace std;

int main()
{  
        system("color 2");
	double num1, num2;
	char operation, redo;  
	cout << "Welcome By:WeedToThePeople)" << endl;
	cout << endl << endl << endl;
	do
	{
		cout << " Choose your poison (+,-,*,/,s)";
		cout << endl;
		cout << "[Type s to swap the numbers]:";
		cin >> operation;
		cout << endl << endl;
		cout << " Type the numbers !";
		cout << operation << "):" << endl << "1st Number-";
		cin >> num1;
		cout << "2nd Number-";
		cin >> num2;
		cout << endl;
		switch (operation)
		{
		case'+':
			cout << "Addition (" << num1 << "," << num2 << "):";
			cout << num1 + num2 << endl;
			break;
		case'-':
			cout << "Subtraction (" << num1 << "," << num2 << "):";
			cout << num1 - num2 << endl;
			break;
		case'*':
			cout << "Multiplaction (" << num1 << "," << num2 << "):";
			cout << num1*num2 << endl;
			break;
		case'/':
			cout << "Division (" << num1 << "," << num2 << "):";
			if (num2 == 0)
			{
				cout << "Nije validno" << endl;
			}
			cout << (num1 / num2) << endl;
			break;
		case's':
			cout << "Swap (" << num1 << "," << num2 << "):";
			swap(num1, num2);
			cout << "I broje=" << num1 << "i II broj=" << num2 << endl << endl;
			break;
		default:
			cout << "IDK WHAT THE FUCK YOU ARE DOING?!" << endl;

		}
		cout << "Type Y or y to continue your math crap:";
		cin >> redo;

		cout << endl << endl;
	} while (redo == 'Y' || redo == 'y');
	system("pause");
	return 0;

}
Kinda stupid but ok ...
You must have just learned the swap function.... Lol

Also, I don't see how this is a tutorial.
Nice I'm gonna test it
Code:
		case'/':
			cout << "Division (" << num1 << "," << num2 << "):";
			if (num2 == 0)
			{
				cout << "Nije validno" << endl;
			}
			cout << (num1 / num2) << endl;
			break;
You're still going to divide by 0 if num2 == 0

Code:
		case's':
			cout << "Swap (" << num1 << "," << num2 << "):";
			swap(num1, num2);
			cout << "I broje=" << num1 << "i II broj=" << num2 << endl << endl;
			break;
What if they put a capital S?

Code:
	system("pause");
	return 0;
Using system("anything") is bad programming.

At the end if you use any letter other than 'y' it will hit end-of-file but it does not exit when you press any key. If you press any key again it hits end-of-file again and then it will exit upon hitting any key.

Also, I don't know if you noticed this
Code:
	cout << "Welcome By:WeedToThePeople)" << endl;
What's the ) for? lol
Hey man , im kinda new to C++, i tested your code on codeblocks, and there was an error that said "expected '}' at the end of input" , not sure exactly where it goes though
Quote Originally Posted by Mulch Diggums View Post
Hey man , im kinda new to C++, i tested your code on codeblocks, and there was an error that said "expected '}' at the end of input" , not sure exactly where it goes though
Check if you forgot to paste the last bracket (The one closing the main function).

Nothing is missing in the code.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us