summaryrefslogtreecommitdiff
path: root/xsc_debug.cpp
blob: 27a8d882d3738d697a14f3f0dc9c4ddacd23499f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

void usage() {
    // Prints usage message (help)
    system("figlet XSC | lolcat");
    cout << "\neXtremelySimpleCalculator usage:\n"
    << "`xsc --help` for help\n"
    << "`xsc <number> <(+|-|*|/|%|^)> <number>` for basic operation calculating\n"
    << "`xsc -r|--sqrt <number>` for square root calculation\n";
}

int main(int argc, char* argv[]) {
    // main::Calculations();
    if (argv[2][0] == '+') {
        cout << atof(argv[1]) + atof(argv[3]);
    }
    else if (argv[2][0] == '-') {
        cout << atof(argv[1]) - atof(argv[3]);
    }
    else if (argv[2][0] == '*') {
        cout << atof(argv[1]) * atof(argv[3]);
    }
    else if (argv[2][0] == '/') {
        cout << atof(argv[1]) / atof(argv[3]);
    }
    else if (argv[2][0] == '%') {
        cout << fmod(atof(argv[1]), atof(argv[3]));
    }
    else if (argv[2][0] == '^') {
        cout << pow(atof(argv[1]), atof(argv[3]));
    }
    else {
        cout << "invalid operator!\n";
        usage();
        return 0;
    }

    // main::Handling();
    if (argv[1] == "--help" || argv[1] == "-h") {
        usage();
        return 0;
    }
    /*
    else if (argc > 4) {
        cout << "too many arguments!\n";
        usage();
        return 1;
    }
    else if (argc < 2) {
        cout << "not enough arguments!\n";
        usage();
        return 1;
    }
    */
}