diff --git a/CalculatorTutorial.sln b/CalculatorTutorial.sln new file mode 100644 index 0000000..5507c5b --- /dev/null +++ b/CalculatorTutorial.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35931.197 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalculatorTutorial", "CalculatorTutorial\CalculatorTutorial.vcxproj", "{01290965-6ADB-473B-B965-F098C05BDC47}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {01290965-6ADB-473B-B965-F098C05BDC47}.Debug|x64.ActiveCfg = Debug|x64 + {01290965-6ADB-473B-B965-F098C05BDC47}.Debug|x64.Build.0 = Debug|x64 + {01290965-6ADB-473B-B965-F098C05BDC47}.Debug|x86.ActiveCfg = Debug|Win32 + {01290965-6ADB-473B-B965-F098C05BDC47}.Debug|x86.Build.0 = Debug|Win32 + {01290965-6ADB-473B-B965-F098C05BDC47}.Release|x64.ActiveCfg = Release|x64 + {01290965-6ADB-473B-B965-F098C05BDC47}.Release|x64.Build.0 = Release|x64 + {01290965-6ADB-473B-B965-F098C05BDC47}.Release|x86.ActiveCfg = Release|Win32 + {01290965-6ADB-473B-B965-F098C05BDC47}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0562D037-FA76-47A4-BDF0-30B09357E0EC} + EndGlobalSection +EndGlobal diff --git a/CalculatorTutorial/CalculatorTutorial.cpp b/CalculatorTutorial/CalculatorTutorial.cpp new file mode 100644 index 0000000..d73a01b --- /dev/null +++ b/CalculatorTutorial/CalculatorTutorial.cpp @@ -0,0 +1,36 @@ +// CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include +#include "Caluculator.h" + +using namespace std; + +int main() +{ + double x = 0.0; + double y = 0.0; + double result = 0.0; + char oper = '+'; + + cout << "Calculator Console Application" << endl << endl; + cout << "Please enter the operation to perform. Format: a+b | a-b | a*b | a/b" << endl; + + Calculator c; + while (true) + { + cin >> x >> oper >> y; + if (oper == '/' && y == 0) + { + cout << "Attempted to divide by zero!" << endl; + continue; + } + else + { + result = c.Calculate(x, oper, y); + } + cout << "Result " << "of " << x << oper << y << " is: " << result << endl; + } + + return 0; +} \ No newline at end of file diff --git a/CalculatorTutorial/CalculatorTutorial.vcxproj b/CalculatorTutorial/CalculatorTutorial.vcxproj new file mode 100644 index 0000000..7c2cb2a --- /dev/null +++ b/CalculatorTutorial/CalculatorTutorial.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {01290965-6adb-473b-b965-f098c05bdc47} + CalculatorTutorial + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/CalculatorTutorial/CalculatorTutorial.vcxproj.filters b/CalculatorTutorial/CalculatorTutorial.vcxproj.filters new file mode 100644 index 0000000..fd6705d --- /dev/null +++ b/CalculatorTutorial/CalculatorTutorial.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + ソース ファイル + + + ソース ファイル + + + + + ヘッダー ファイル + + + \ No newline at end of file diff --git a/CalculatorTutorial/Caluculator.cpp b/CalculatorTutorial/Caluculator.cpp new file mode 100644 index 0000000..6d7ba53 --- /dev/null +++ b/CalculatorTutorial/Caluculator.cpp @@ -0,0 +1,18 @@ +#include "Caluculator.h" + +double Calculator::Calculate(double x, char oper, double y) +{ + switch (oper) + { + case '+': + return x + y; + case '-': + return x - y; + case '*': + return x * y; + case '/': + return x / y; + default: + return 0.0; + } +} \ No newline at end of file diff --git a/CalculatorTutorial/Caluculator.h b/CalculatorTutorial/Caluculator.h new file mode 100644 index 0000000..8b97300 --- /dev/null +++ b/CalculatorTutorial/Caluculator.h @@ -0,0 +1,6 @@ +#pragma once +class Calculator +{ +public: + double Calculate(double x, char oper, double y); +}; \ No newline at end of file