Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //calculator
- #include <iostream>
- #include <math.h>
- using namespace std;
- float addition (float a);
- float subtraction (float a, float b);
- float multiplication (float a);
- float division (float a, float b);
- float power (float a, float b);
- float radix (float a, float b);
- float sincostan (float a);
- float log (float a);
- float pythagorasc (float a, float b);
- float pythagorasb (float a, float c);
- float arcsincostan (float a);
- float quadrateq (float a, float b,float c, float x);
- float percentage (float a, float b);
- float systems2 (float a, float b, float c, float d, float e, float f, float x, float y);
- int main(int x, float a, float b, float c, float d, float e, float f, float y, int p)
- {
- loop:
- cout << endl;
- cout << "D-CALC (powered by D-CODES) V 1.1" << endl;
- cout << endl;
- cout << "1 for addition" << endl;
- cout << "2 for subtraction" << endl;
- cout << "3 for multiplication" << endl;
- cout << "4 for division" << endl;
- cout << "5 for power" << endl;
- cout << "6 for root" << endl;
- cout << "7 for sin/cos/tan" << endl;
- cout << "8 for logarythmus" << endl;
- cout << "9 for pythagoras: hypotenuse unknown" << endl;
- cout << "10 for pythagoras: leg unknown" << endl;
- cout << "11 for arcsin/-cos/-tan" << endl;
- cout << "12 for quadratic equation" << endl;
- cout << "13 for percentage" << endl;
- cout << "14 for quadratic systems" << endl;
- cout << endl;
- cout << "Select an operation: ";
- cin >> x;
- cout << endl;
- if (x==1)
- addition (a);
- else if (x==2)
- subtraction (a, b);
- else if (x==3)
- multiplication (a);
- else if (x==4)
- division (a, b);
- else if (x==5)
- power (a, b);
- else if (x==6)
- radix (a, b);
- else if (x==7)
- sincostan (a);
- else if (x==8)
- log (a);
- else if (x==9)
- pythagorasc (a, b);
- else if (x==10)
- pythagorasb (a, c);
- else if (x==11)
- arcsincostan (a);
- else if (x==12)
- quadrateq (a, b, c, x);
- else if (x==13)
- percentage (a, b);
- else if (x==14)
- systems2 (a, b, c, d, e, f, x, y);
- cout << endl;
- cout << "Thank's for using D-CODES software";
- cout << endl;
- cout << endl;
- cout << "Enter 1 to repeat / 0 to finish: ";
- cin >> p;
- if (p==1)
- {
- goto loop;
- }
- return 0;
- }
- float addition (float a)
- {
- for (;a>0;)
- {
- float b;
- cout << "Enter addend (0 for sum): ";
- cin >> a;
- b+=a;
- if (a==0)
- {
- cout << endl;
- cout << "The sum of the entered numbers is: " << b << endl;
- }
- }
- }
- float subtraction (float a, float b)
- {
- float c;
- cout << "Enter subtrahend: ";
- cin >> a;
- cout << "Enter minuend (press 0 for difference): ";
- cin >> b;
- c=a-b;
- for (;a>0;)
- {
- cout << "Enter minuend (press 0 for difference): ";
- cin >> b;
- c-=b;
- if (b==0)
- {
- cout << endl;
- cout << "The difference of the entered numbers is: " << c << endl;
- break;
- }
- }
- }
- float multiplication (float a)
- {
- float b;
- cout << "Enter factor (press 1 for product): ";
- cin >> a;
- cout << "Enter factor (press 1 for product): ";
- cin >> b;
- b=a*b;
- for (;a>0;)
- {
- cout << "Enter factor (press 1 for product): ";
- cin >> a;
- b*=a;
- if (a==1)
- {
- cout << endl;
- cout << "The product of the entered numbers is: " << b << endl;
- break;
- }
- }
- }
- float division (float a, float b)
- {
- float c;
- cout << "Enter dividend: ";
- cin >> a;
- cout << "Enter divisor (press 1 for difference): ";
- cin >> b;
- c=a/b;
- for (;a>0;)
- {
- cout << "Enter divisor (press 1 for difference): ";
- cin >> b;
- c/=b;
- if (b==1)
- {
- cout << endl;
- cout << "The quotient of the entered numbers is: " << c << endl;
- break;
- }
- }
- }
- float power (float a, float b)
- {
- cout << "Enter base: ";
- cin >> a;
- cout << "Enter exponent: ";
- cin >> b;
- cout << a << "^" << b << " = " << pow(a,b) << endl;
- }
- float radix (float a, float b)
- {
- cout << "Enter radicand: ";
- cin >> a;
- cout << "Enter order: ";
- cin >> b;
- cout << b << "^sqrt(" << a << ") = " << pow(a,(1/b)) << endl;
- }
- float sincostan (float a)
- {
- cout << "Enter a number: ";
- cin >> a;
- cout << "sin(" << a << ") = "<< sin(a) << endl;
- cout << "cos(" << a << ") = "<< cos(a) << endl;
- cout << "tan(" << a << ") = "<< tan(a) << endl;
- }
- float log (float a)
- {
- cout << "Enter a number: ";
- cin >> a;
- cout << "log10(" << a << ") = " << log10(a) << endl;
- }
- float pythagorasc (float a, float b)
- {
- cout << "Enter first leg: ";
- cin >> a;
- cout << "Enter second leg: ";
- cin >> b;
- cout << "sqrt( " << a << "^2 + " << b << "^2 ) = " << sqrt((pow(a,2))+(pow(b,2))) << endl;
- }
- float pythagorasb (float a, float c)
- {
- cout << "Enter leg: ";
- cin >> a;
- cout << "Enter hypotenuse: ";
- cin >> c;
- cout << "sqrt( " << a << "^2 - " << c << "^2 ) = " << sqrt((pow(a,2))-(pow(c,2))) << endl;
- }
- float arcsincostan (float a)
- {
- cout << "Enter a number: ";
- cin >> a;
- cout << "arcsin(" << a << ") = "<< asin(a) << endl;
- cout << "arccos(" << a << ") = "<< acos(a) << endl;
- cout << "arctan(" << a << ") = "<< atan(a) << endl;
- }
- float quadrateq (float a, float b,float c, float x)
- {
- cout << "Enter coefficient (a) of x^2: ";
- cin >> a;
- cout << "Enter coefficient (b) of x: ";
- cin >> b;
- cout << "Enter constant (c): ";
- cin >> c;
- cout << "x1 = (" << b << " + sqrt(" << b << "^2 - 4*" << a << "*" << c <<"))/( 2*" << a << ") = " << (b+sqrt(pow(b,2)-4*a*c))/(2*a) << endl;
- cout << "x2 = (" << b << " - sqrt(" << b << "^2 - 4*" << a << "*" << c <<"))/( 2*" << a << ") = " << (b-sqrt(pow(b,2)-4*a*c))/(2*a) << endl;
- }
- float percentage (float a, float b)
- {
- cout << "Enter a number: ";
- cin >> a;
- cout << "Enter the percentage: ";
- cin >> b;
- cout << b << "% of " << a << " is: " << a*(b/100) << endl;
- }
- float systems2 (float a, float b, float c, float d, float e, float f, float x, float y)
- {
- cout << "Enter coefficient (a) of x: ";
- cin >> a;
- cout << "Enter coefficient (b) of y: ";
- cin >> b;
- cout << "Enter constant (c): ";
- cin >> c;
- cout << a << "*x + " << b << "*y = " << c << endl;
- cout << "Enter coefficient (d) of x: ";
- cin >> d;
- cout << "Enter coefficient (e) of y: ";
- cin >> e;
- cout << "Enter constant (f): ";
- cin >> f;
- cout << d << "*x + " << e << "*y = " << f << endl;
- cout << "x is: " << ((b*f)-(e*c))/((b*d)-(a*e)) << endl;
- cout << "y is: " << (c-(a*x))/b << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement