Как вывести ноль в калькуляторе?
Итак, я новичок, и мне нужно было создать калькулятор. Проблема в том, что я не знаю, как сделать так, чтобы если "4 / 0 = 0; 9/0= 0" и так далее.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sav4 { class Program { static void Main(string[] args) { char x; double a; double b; double ats; Console.WriteLine("insert first number "); a = double.Parse(Console.ReadLine()); Console.WriteLine("insert second number "); b = double.Parse(Console.ReadLine()); Console.WriteLine("insert inc "); // - + * / x = (char)Console.Read(); Console.Clear(); if (x == '-' ) { ats = a - b; Console.WriteLine("{0} - {1} = {2}", a, b, ats); } else { if (x == '+') { ats = a + b; Console.WriteLine("{0} + {1} = {2}", a, b, ats); } else { if (x == '*') { ats = a * b; Console.WriteLine("{0} * {1} = {2}", a, b, ats); } else { if (x == '/') { ats = a / b; if (a/b != 0) { Console.WriteLine("{0} / {1} = {2}", a, b, ats); } else { Console.WriteLine("Lygybe neegzistuoja", a, b, ats); } } else { Console.WriteLine("Error"); } } } } } } }
Что я уже пробовал:
Я думаю, что много думаю, вот и все