2018-11-15 15:07:05 +02:00
|
|
|
#include "calculator.h"
|
|
|
|
|
2018-11-15 15:21:34 +02:00
|
|
|
int Calculator::Add (double a, double b)
|
2018-11-15 15:07:05 +02:00
|
|
|
{
|
2018-11-15 15:28:04 +02:00
|
|
|
return a + b + 0.5;
|
2018-11-15 15:07:05 +02:00
|
|
|
}
|
2018-11-15 15:17:29 +02:00
|
|
|
|
2018-11-15 15:21:34 +02:00
|
|
|
int Calculator::Sub (double a, double b)
|
2018-11-15 15:17:29 +02:00
|
|
|
{
|
2018-11-15 15:21:34 +02:00
|
|
|
return Add (a, -b);
|
2018-11-15 15:17:29 +02:00
|
|
|
}
|
2024-10-10 18:43:08 +03:00
|
|
|
|
|
|
|
int Calculator::Mul (double a, double b)
|
|
|
|
{
|
|
|
|
return a * b + 0.5;
|
|
|
|
}
|
2024-10-10 19:13:51 +03:00
|
|
|
|
|
|
|
double Calculator::Pow(double a, int n)
|
|
|
|
{
|
|
|
|
double result = 1;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
result *= a;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|