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); } } }
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.
+ 2
You are asking for the x value twice, so you should use int x = Convert.ToInt32(str);
+ 1
https://code.sololearn.com/c7q3qnvRGNP9
Here's the link to it in Code Playground
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.
0
Okay...
Well, it's an assignment from their own course. Where can I test it?
0
If you want to use it with the loop, you have to run it on your PC.