#include #include #include #include int addition(); int substract(); int multiplication(); int division(); int info(); using namespace std; int main() { int a, b; system("cls"); cout << "List: " << endl; cout << "1: Addition" << endl << "2: Substraction" << endl << "3: Multiplication" << endl << "4: Division" << endl << "5: Info" << endl << "6: Exit" << endl; cout << "Chose what to do: "; cin >> a; cout << endl; switch(a) { case 1: addition(); break; case 2: substract(); break; case 3: multiplication(); break; case 4: division(); break; case 5: info(); break; case 6: void exit (int exitcode); default: main(); break; } } int addition() { int a, b; cout << setw(12) << "Addition" << endl; cout << "First number "; cin >> a; cout << "Second number "; cin >> b; cout << a << " + " << b << " = " << a+b << endl; ofstream myfile; myfile.open ("Calculator.txt",ios::app); myfile << a << " + " << b << "= " << a+b << "\n"; myfile.close(); cout << endl << endl; cout << "Press any key to go back to the menu."; getch(); main(); } int substract() { int a, b; cout << setw(4) << "Substraction" << endl; cout << "First number "; cin >> a; cout << "Second number "; cin >> b; cout << a << " - " << b << " = " << a-b << endl; ofstream myfile; myfile.open ("Calculator.txt",ios::app); myfile << a << " - " << b << "= " << a-b << "\n"; myfile.close(); cout << "Press any key to go back to the menu."; getch(); main(); } int multiplication() { int a, b; cout << setw(4) << "Multiplication" << endl; cout << "First number "; cin >> a; cout << "Second number "; cin >> b; cout << a << " * " << b << " = " << a*b << endl; ofstream myfile; myfile.open ("Calculator.txt",ios::app); myfile << a << " * " << b << "= " << a*b << "\n"; myfile.close(); cout << "Press any key to go back to the menu."; getch(); main(); } int division() { int a, b; cout << setw(4) << "Division" << endl; cout << "First number "; cin >> a; cout << "Second number "; cin >> b; cout << a << " / " << b << " = " << a/b << endl; ofstream myfile; myfile.open ("Calculator.txt",ios::app); myfile << a << " / " << b << "= " << a/b << "\n"; myfile.close(); cout << "Press any key to go back to the menu."; getch(); main(); } int info() { cout << "At the moment this program don't have any command to exit, so to exist you have to press the x-button on the upper right corner. \n\nSecond; this program don't have to many options to use several different \nnumbers or operators at once, so instead all your data is saved in a text \ndocument in the same folder as your exe-file is." << endl << endl; cout << "Press any key to go back to the menu."; getch(); main(); }