Hey, i started learning C++ week ago, and having fun , anyway i wrote a simple C++ Calculator it works ^^, just wondering, how is my c++ code ? i mean from a professional perspective..
this is how it looks: Gyazo - ac0f873000fd200013e860f00873fec1.png
Code:
// DECLARATIONS ---------------------------
#include <iostream>
#include <string>
#include <conio.h>
#include <fstream>
// FUNCTION DECLARATIONS ------------------
bool DRAW_INTERFACE();
int math();
// MAIN FUNCTION --------------------------
int main() {
if (!DRAW_INTERFACE()) return 0;
_getch();
math();
return 0;
std::cin.get();
system("pause");
}
// DRAW INTERFACE -------------------------
bool DRAW_INTERFACE() {
std::cout<<"Checking INTERACE.TXT... ";
std::ifstream FILE("INTERFACE.TXT");
if (!FILE.good()) {
std::cout<<"ERROR: FILE NOT FOUND.";
return false;
}
else {
system("cls");
while (!FILE.eof()) {
std::string FILE_LINE;
std::getline(FILE, FILE_LINE);
std::cout<<FILE_LINE<<std::endl;
}
}
return true;
}
// MATH OPERATION -------------------------
int math() {
float a, b, result;
char operation;
std::cin >> a >> operation >> b;
switch (operation) {
case '+' :
result = a + b;
break;
case '-' :
result = a - b;
break;
case '*' :
result = a * b;
break;
case '/' :
result = a / b;
break;
default :
std::cout << "Try entering an exercise for example( 16 * 16 )" << std::endl;
}
std::cout<<"Your answer is: "<<result<<std::endl;
system("pause");
return true;
}