diff --git a/src/main.c b/src/main.c index b6e7eaf..7573230 100644 --- a/src/main.c +++ b/src/main.c @@ -10,13 +10,11 @@ int main(const int argc, const char *const *const argv) { interval_t interval = 0; int res = parse_arguments(argc, argv, &price, &wattage, &interval); - if (res != 0) { - if (res == 1) - print_usage(); - else if (res == 2) - print_version(); - exit(0); - } + switch (res) { + case 1: print_usage(); exit(0); + case 2: print_version(); exit(0); + case 99: fputs("Unknown flag provided.\n", stderr); print_usage(); exit(1); + } printf("%.2Lf\n", (price * wattage) * interval);