//1.This is my current code for a calculator,
//I need to make it continuous until the user press =.
//2. How do I change the functions of this calculator into
//something that embeds into an object class?
cout << "Please input the second number" << endl;
cin >> number2;
switch (operation)
{
case '+':
result = number1 + number2;
break;
case '-':
result = number1 - number2;
break;
case '*':
result = number1 * number2;
break;
case '/':
result = number1 / number2;
break;
default:
goto retry;
break;
}
cout << endl;
if (number2 == 0)
cout << "Error!!! " << endl;
else
cout << "The result is: " << result << endl;
cout << endl;
Here's an older thread where I tried to explain how to do that: http://www.cplusplus.com/forum/beginner/36637/#msg199334
See my other posts in that thread too.
This doesn't tell you how to use classes for it, but when you have the algorithm figured out, slight restructuring should not be any trouble.
This is what I have so far. I'm not sure how to incorporate the class NCalculator into my program after declaring it.
These are some pointers I got from the professor, but I am still unsure how to do this:
"you're going to have a loop for your arithmetic cycle, and if
statements to determine which method inside your class you're going to
be calling."
___________________________________________________________________________
#include <iostream>
using namespace std;