0

C# So the programm assaigns the first double x with console.read() but the y and the ß double are just not excuted. Whats wrong?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Calculator {class Program     { static void Main(string[] args)         { double x;             double ß;             double y;             bool b = false; Console.WriteLine("Calculator"); Console.WriteLine("Paste the first number");             x = Console.Read(); Console.WriteLine("Chose youre Symbol <0 = +> <1 = -> <2 = *> <3 = />");             ß = Console.Read(); Console.WriteLine("Paste the last number"); y = Console.Read();   if (ß == 0)             { Console.Write(x + y);                 b = true; }  if (ß == 1)             { Console.Write(x - y);                b = true; } if (ß == 2)             { Console.Write(x * y);                 b = true; }  if (ß == 3)             { Console.Write(x / y);                 b = true;} //Check if the number for ß was correct if (b == false)             {Console.Write("Error");}}}} //Sorry for my english

6th Aug 2018, 9:28 PM
shinja yo
shinja yo - avatar
1 Réponse
0
psst, use double.Parse(Console.Read()) when taking double values from the input. Also, if we're talking the SL compiler, all inputs have to be put in at the start.
7th Aug 2018, 7:11 AM
hinanawi
hinanawi - avatar