Calculator v1
Просто написал что то простенькое не ломающееся
This commit is contained in:
parent
925719236c
commit
4b0fb80207
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Calculator/Calculator/bin/Debug/net8.0/Calculator.deps.json
Normal file
23
Calculator/Calculator/bin/Debug/net8.0/Calculator.deps.json
Normal 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": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.dll
Normal file
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.dll
Normal file
Binary file not shown.
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.exe
Normal file
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.exe
Normal file
Binary file not shown.
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.pdb
Normal file
BIN
Calculator/Calculator/bin/Debug/net8.0/Calculator.pdb
Normal file
Binary file not shown.
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"runtimeOptions": {
|
||||||
|
"tfm": "net8.0",
|
||||||
|
"framework": {
|
||||||
|
"name": "Microsoft.NETCore.App",
|
||||||
|
"version": "8.0.0"
|
||||||
|
},
|
||||||
|
"configProperties": {
|
||||||
|
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user