Skip to content
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
25 changes: 25 additions & 0 deletions Homework05/Homework05.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 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Homework05", "Homework05\Homework05.csproj", "{4CB9E2B0-4B50-4947-85FC-2E00393DA325}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4CB9E2B0-4B50-4947-85FC-2E00393DA325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CB9E2B0-4B50-4947-85FC-2E00393DA325}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CB9E2B0-4B50-4947-85FC-2E00393DA325}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CB9E2B0-4B50-4947-85FC-2E00393DA325}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B7C80557-3166-4939-A5C0-521CB9130E95}
EndGlobalSection
EndGlobal
17 changes: 17 additions & 0 deletions Homework05/Homework05/CannotEnterAnotherSymbolException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework05
{
internal class CannotEnterAnotherSymbolException : Exception
{
public CannotEnterAnotherSymbolException(string str)
: base (str)
{

}
}
}
10 changes: 10 additions & 0 deletions Homework05/Homework05/Homework05.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
59 changes: 59 additions & 0 deletions Homework05/Homework05/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace Homework05
{
internal class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Shell we start calculating!");
Console.Write("Enter first number : ");
int firstNumber = int.Parse(Console.ReadLine());
Console.Write("Enter action :");
char action = Console.ReadLine()[0];
Console.Write("Enter second number : ");
int secondNumber = int.Parse(Console.ReadLine());

Calculate(firstNumber, secondNumber, action);

}
catch (CannotEnterAnotherSymbolException ex)
{
Console.WriteLine("Wrong symbol . Please, try again");
}
catch (Exception ex)
{
Console.WriteLine("Something went wrong!");
}
Thread.Sleep(3000);
Console.Clear();
Main(args);
}

public static void Calculate(int firstNum, int secondNum, char action)
{
int result;

switch (action)
{
case '+':
result = firstNum + secondNum;
break;
case '-':
result = firstNum - secondNum;
break;
case '*':
result = firstNum * secondNum;
break;
case '/':
result = firstNum / secondNum;
break;
default: throw new CannotEnterAnotherSymbolException("Wrong symbol!");
}
Console.Clear();
Console.WriteLine($"{firstNum} {action} {secondNum} = {result}");

}

}
}
1 change: 1 addition & 0 deletions Homework05/Homework05/errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Value does not fall within the expected range.