0

Is there any short way/short this code to do same work?

Here the code that I have create. Tell me the short way if have. { start: int num01; int num02; string symble; string EnC; string userMail; string userPass; Console.WriteLine("Welcome to SheikhAbirBL\nChoose your option Calculator or LoginSystem\nWrite cal for Calculator login for LoginSystem"); EnC = Console.ReadLine(); if (EnC == "cal") { goto cal; } else if (EnC == "login") { goto logIn; } else { Console.WriteLine("Something went wrong\nPress any key to continue"); Console.ReadKey(); Console.Clear(); goto start; } cal: do { Console.WriteLine("Enter your first number "); num01 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input a operetor"); symble = Convert.ToString(Console.ReadLine()); Console.WriteLine("Enter your second number"); num02 = Convert.ToInt32(Console.ReadLine()); if (symble == "*") { Console.WriteLine("Result is " + (num01 * num02)); } else if (symble == "/") { Console.WriteLine("Result is " + (num01 / num02)); } else if (symble == "-") { Console.WriteLine("Result is " + (num01 - num02)); } else if (symble == "+") { Console.WriteLine("Result is " + (num01 + num02)); } else if (symble == "%") { Console.WriteLine("Result is " + (num01 % num02));

19th Nov 2016, 11:04 AM
Habibur Rahman
Habibur Rahman - avatar
1 ответ
0
First off remember this principle once and forever: NEVER use "goto". It is easier and safer to do it with loops.
19th Nov 2016, 12:35 PM
Jakub Stasiak
Jakub Stasiak - avatar