From bc8b03321b9005ff5e44e8cae3b16d5ceee7b1a3 Mon Sep 17 00:00:00 2001 From: anushhada46 Date: Sat, 17 Oct 2020 10:51:26 +0545 Subject: [PATCH] Hacktober Commit --- calculator/Program.cs | 58 ++++++++++++++++++++++++++++++++++++ calculator/calculator.csproj | 8 +++++ calculator/calculator.sln | 25 ++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 calculator/Program.cs create mode 100644 calculator/calculator.csproj create mode 100644 calculator/calculator.sln diff --git a/calculator/Program.cs b/calculator/Program.cs new file mode 100644 index 00000000..b0272ed6 --- /dev/null +++ b/calculator/Program.cs @@ -0,0 +1,58 @@ +using System; + +namespace Calculator +{ + class Program + { + static void Main(string[] args) + { + int firstNum; + int secondNum; //Variables for equation + string operation; + int answer; + + Console.WriteLine("Hello, welcome to Alex's basic calculator!"); + Console.ReadLine(); + + Console.Write("Enter the first number in your basic equation: "); + firstNum = Convert.ToInt32(Console.ReadLine()); + + //User input for equation + Console.Write("Now enter your second number in the basic equation: "); + secondNum = Convert.ToInt32(Console.ReadLine()); + Console.Write("Ok now enter your operation ( x , / , +, -) "); + operation = Console.ReadLine(); + + if (operation == "x") + { + answer = firstNum * secondNum; + Console.WriteLine(firstNum + "*" + secondNum " = " + answer); + Console.ReadLine(); + } + else if (operation == "/") + { + answer = firstNum / secondNum; + Console.WriteLine(firstNum + " / " + secondNum + " = " + answer); + Console.ReadLine(); + } + //Getting answers + else if (operation == "+") + { + answer = firstNum + secondNum; + Console.WriteLine(firstNum + " + " + secondNum + " = " + answer); + Console.ReadLine(); + } + else if (operation == "-") + { + answer = firstNum - secondNum; + Console.WriteLine(firstNum + " - " + secondNum + " = " + answer); + Console.ReadLine(); + } + else + { + Console.WriteLine("Sorry that is not correct format! Please restart!"); //Catch + Console.ReadLine(); + } + } + } +} diff --git a/calculator/calculator.csproj b/calculator/calculator.csproj new file mode 100644 index 00000000..c73e0d16 --- /dev/null +++ b/calculator/calculator.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/calculator/calculator.sln b/calculator/calculator.sln new file mode 100644 index 00000000..58d6c408 --- /dev/null +++ b/calculator/calculator.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30503.244 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "calculator", "calculator.csproj", "{2B0AD7A6-B52A-4812-97E5-705177AB0734}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2B0AD7A6-B52A-4812-97E5-705177AB0734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B0AD7A6-B52A-4812-97E5-705177AB0734}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B0AD7A6-B52A-4812-97E5-705177AB0734}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B0AD7A6-B52A-4812-97E5-705177AB0734}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7A1FD661-43B5-4D53-9E09-B56EDDC8A1CB} + EndGlobalSection +EndGlobal