Take it and compile it, see how it works.
Updated again, sad how you didn't see the progress.
Also, I have no idea how to "name" versions, like 1.2.3.4, so I went for what felt right
Code:/* Name: Calculator 1.2.2 Author: Silkey Katzewurzt Date: 26-07-07 21:49 Description: A calulator! */ #include <iostream> using namespace std; int add(int a,int b); int sub(int a,int b); int mul(int a,int b); int divi(int a,int b); int main() { char command; int a; int number = 0; int saved = 0; string avCom = "+,-,*,/"; string instructions = "\nThis works just like a normal calculator," " available commands are: \nTo reset your calculation, " "type in 'c' and then any number,\nand it will reset to 0." "\nTo save, type in 'm' and then any number." "\nTo load a saved calculation, type in 'l' and then any number." "\nTo see these instructions, type in i and then any number.\n"; cout<<instructions; cout<<"\n\n"<<number<<"\n"; while(true){ cout<<"\n"; cin>>command>>a; switch(command) { case '+': cout<<number<<" plus "<<a<<" equals to "<<add(number,a); number = add(number,a); break; case '-': cout<<number<<" minus "<<a<<" equals to "<<sub(number,a); number = sub(number,a);; break; case '*': cout<<number<<" multiplied by "<<a<<" equals to "<<mul(number,a); number = mul(number,a); break; case '/': cout<<number<<" divided by "<<a<<" equals to "<<divi(number,a); number = number/a; break; case 'm': cout<<number<<" has been saved.\n"; saved = number; break; case 'l': cout<<saved<<" has been loaded.\n"; number = saved; break;; case 'c': cout<<"Your calculation has been reset."; number = 0; break; case 'i': cout<<instructions; break; default: cout<<"No such command.\n"; break; } } } int add(int a,int b) { return a+b; } int sub(int a,int b) { return a-b; } int mul(int a,int b) { return a*b; } int divi(int a,int b) { return a/b; } /* 26-07-07 22:02 26-07-07 22:39 26-07-07 23:15 */



LinkBack URL
About LinkBacks




