Calculator v1

Просто написал что то простенькое не ломающееся
This commit is contained in:
dkwoodik 2025-11-22 23:59:41 +04:00
parent 925719236c
commit 4b0fb80207
6 changed files with 160 additions and 2 deletions

View File

@ -1,2 +1,125 @@
// See https://aka.ms/new-console-template for more information using System;
Console.WriteLine("Hello, World!");
namespace Calculator
{
class Calculator
{
public static void Main(string[] args)
{
var Cal = new Calculator();
Cal.Start();
}
public void Start()
{
while (true)
{
Console.WriteLine("Начало:");
string a = Console.ReadLine();
int b = 0;
switch (a)
{
case "+":
Console.WriteLine("Введите числа:");
for (int i = 0; i == b;)
{
do
{
try
{
b = Convert.ToInt32(Console.ReadLine());
i += b;
if (b > 0)
b -= 1;
Console.WriteLine($"Вывод: {i}");
}
catch
{
Console.WriteLine("Неверный синтаксис!");
continue;
}
} while (a == "+" && b != 0);
Console.WriteLine("Конец сложения");
break;
}
break;
case "-":
Console.WriteLine("Введите числа:");
for (int i = 0; i == b;)
{
do
{
try
{
int c = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
i = c -= b;
if (b > 0)
b -= 1;//нужно исправить вылетает когда 1 пишем
Console.WriteLine($"Вывод: {i}");
}
catch
{
Console.WriteLine("Неверный синтаксис!");
continue;
}
} while (a == "-" && b != 0);
}
Console.WriteLine("Конец вычитания");
break;
case "*":
Console.WriteLine("Введите числа:");
b = 1;
for (int i = 1; i == b;)
{
do
{
try
{
b = Convert.ToInt32(Console.ReadLine());
i *= b;
if (b > 0)
b -= 1;
Console.WriteLine($"Вывод: {i}");
}
catch
{
Console.WriteLine("Неверный синтаксис!");
continue;
}
} while (a == "*" && b != 0);
}
break;
case "/":
float g = 0;
Console.WriteLine("Введите числа:");
for (float i = 0f; i == g;)
{
do
{
try
{
float c = Convert.ToInt32(Console.ReadLine());
g = Convert.ToInt32(Console.ReadLine());
i = c /= g;
if (g > 0f)
g -= 1;
Console.WriteLine($"Вывод: {i}");
}
catch
{
Console.WriteLine("Неверный синтаксис!");
continue;
}
} while (a == "/" && g != 0);
}
break;
}
}
}
}
}

View File

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Calculator/1.0.0": {
"runtime": {
"Calculator.dll": {}
}
}
}
},
"libraries": {
"Calculator/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}