Remember C++ class in H.S. hehehe
This is a program half built that needs finished and I need to find someone who can finish it for me real quick like.
Lets make a calculator.
#include <iostream.h> //reference to cout
//Stack class code goes here
// The book would probably provide a valuable reference for a stack..
class Stack
{
Stack()
{
cout << "\n If you are seeing this, you have not implemented a stack\n";
}
};
/**
* My postfix notation calculator does ...
*
*/
class PostFixCalculator
{
public:
PostFixCalculator();
PostFixCalculator(int operand1, int operand2, char op);
/**
* Return the top element of the stack but do not remove it.
*/
int view();
/**
* Add an operand to the stack
*/
void add(int );
/**
* Execute the operator on the top two elements of the
* stack. Push the results back onto the stack and
* return the same value.
*/
int add(char);
private:
Stack operand;
};
//Implement code here
int main(int argc, char * argv[])
{
const char plus = '+', minus = '-', divide = '/', multiply = '*',
mod = '%';
PostFixCalculator p;
PostFixCalculator c(5, 5, multiply);
PostFixCalculator p2;
p.add(5);
p.add(5);
p.add(7);
p.add(0);
p.add(plus);
p.add(minus);
p.add(multiply);
p2.add(7);
p2.add(3);
p2.add(mod); //p2.view should be equal to 1
p2.add(16);
p2.add(plus); //p2.view should be equal to 17
p2.add(0);
p2.add(10);
p2.add(3);
p2.add(1);
p2.add(52);
p2.add(37);
p2.add(1);
p2.add(6);
p2.add(548);
p2.add(multiply); //p2.view should be 3288
p2.add(multiply); //p2.view should be 3288
p2.add(mod); //p2.view should be 37
p2.add(multiply); //p2.view should be 1924
p2.add(multiply); //p2.view should be 1924
p2.add(multiply); //p2.view should be 5772
p2.add(mod); //p2.view should be 10
p2.add(multiply); //p2.view should be 0
p2.add(plus); //p2.view should be 17
p2.add(0);
p2.add(minus); //p2.view should be 17
if (p.view() == -10)
cout << "Things are going well for you \n";
else
cout << "Something's wrong with your code\n";
if (c.view() == 25)
cout << "Excellent \n";
else
cout << "Something's wrong with your non-default constructor \n";
if (c.view() == 17)
cout << "Fantastic work \n";
else
cout <<"Looks like something's amiss\n";
return 0;
}