Skip to content

Hacktober Commit #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions calculator/Program.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
8 changes: 8 additions & 0 deletions calculator/calculator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions calculator/calculator.sln
Original file line number Diff line number Diff line change
@@ -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