0

Can't seem to get the Easy Calculator to work

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { do{ Console.WriteLine("x = "); string str = Console.ReadLine(); if (str == "Exit") break; int x = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("y ="); int y = Convert.ToInt32(Console.ReadLine()); int sum = x+y; Console.WriteLine("Result:{0}", sum); } while(true); } } }

19th Dec 2017, 3:36 PM
Linus Eriksson
Linus Eriksson - avatar
6 Answers
+ 3
It would be simpler if you put your code into code playground, then you can easily change it, and we can look over it faster.
19th Dec 2017, 4:37 PM
Jonas Schröter
Jonas Schröter - avatar
+ 2
You are asking for the x value twice, so you should use int x = Convert.ToInt32(str);
19th Dec 2017, 8:29 PM
Moritz Vogel
Moritz Vogel - avatar
+ 1
https://code.sololearn.com/c7q3qnvRGNP9 Here's the link to it in Code Playground
21st Dec 2017, 4:33 PM
Linus Eriksson
Linus Eriksson - avatar
0
You can't run this code in the code playground, because it's in an infinite loop, so the result will never be printed. Just remove the loop.
21st Dec 2017, 4:36 PM
Moritz Vogel
Moritz Vogel - avatar
0
Okay... Well, it's an assignment from their own course. Where can I test it?
21st Dec 2017, 4:53 PM
Linus Eriksson
Linus Eriksson - avatar
0
If you want to use it with the loop, you have to run it on your PC.
21st Dec 2017, 4:55 PM
Moritz Vogel
Moritz Vogel - avatar