home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
- #include <fstream.h>
- #include "..\hugecalc.hpp"
-
- void powers();
- void arith();
- void relation();
-
- int main()
- {
- int ch;
- do
- {
- cout << "HugeCalc Demonstration Program" << endl
- << "By Zvika Ben-Haim" << endl << endl
- << "Select a number and press Enter:" << endl << endl
- << "1. Calculation of Powers" << endl
- << "2. Arithmetic Operators" << endl
- << "3. Relational Operators" << endl
- << "4. Quit" << endl;
- cin >> ch;
- switch(ch)
- {
- case 1: powers(); break;
- case 2: arith(); break;
- case 3: relation(); break;
- }
- }
- while(ch!=4);
- return 0;
- }
-
- void powers()
- {
- HugeInt a=1,b=1;
- int i, j, x, y;
- ofstream file;
- cout << endl << "Power Calculator" << endl
- << "Calculate x^y with complete accuracy!" << endl << endl
- << "Enter x: ";
- cin >> x;
- cout << "Enter y: ";
- cin >> y;
- file.open("powers.dat",ios::out);
- file << "Powers of " << x << endl << endl;
- for(j=1; j<=y; j++)
- {
- /* a=b;
- for(i=1; i<x; i++)
- b=b+a;*/
- b *= x;
- file << j << ":\t" << b << endl;
- }
- file.close();
- cout << "Powers were saved to file 'powers.dat'" << endl << endl;
- }
-
- void relation()
- {
- HugeInt a,b;
- cout << endl << "Relationship Operators Demonstration" << endl
- << "Enter value of a: ";
- cin >> a;
- cout << "Enter value of b: ";
- cin >> b;
- if(a==b) cout << "a==b" << endl;
- if(a>b) cout << "a>b" << endl;
- if(a<b) cout << "a<b" << endl;
- if(a>=b) cout << "a>=b" << endl;
- if(a<=b) cout << "a<=b" << endl;
- }
-
- void arith()
- {
- HugeInt a,b;
- char ch;
- cout << endl << "Arithmetic Operators Demonstration" << endl
- << "Enter value of a: ";
- cin >> a;
- cout << "Enter value of b: ";
- cin >> b;
- cout << "a+b=" << a+b << endl;
- cout << "a-b=" << a-b << endl;
- cout << "b-a=" << b-a << endl;
- cout << "a*b=" << a*b << endl << endl;
- }
-
-