+ 1

How much is wrong with this code?

I'm trying to use switch statements to create a basic calculator. I am 1.5 months into learning c# so be gentle when you describe how dumb some of my methods are.

19th Jan 2018, 5:13 PM
david kerkel
david kerkel - avatar
6 Answers
+ 6
Please make the code public or post a link to the code so we can see it.
19th Jan 2018, 9:40 PM
Rrestoring faith
Rrestoring faith - avatar
+ 5
We can’t see the code.
19th Jan 2018, 5:23 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 4
There's lots of minor errors here. You forgot a semi-colon on lines: 32, 37, 42, and 47. You created 2 Strings with the same name. To fix this change line 27 from this: string yourOperation = ConsoleReadLine(); to this: yourOperation = Console.ReadLine(); On line 32, remove the extra space between 'num' and '2' so that it reads num2. On line 29, remove the extra semi-colon after your switch statement. It should look like this: switch (yourOperation) { Finally, all of your cases should be in quotes because these are strings. Like this: case "add": etc... same thing with the subtract, multiply and divide case. After those fixes it works.
20th Jan 2018, 1:37 AM
Rrestoring faith
Rrestoring faith - avatar
+ 2
Link and public, if it is not public the link won’t work.
19th Jan 2018, 10:16 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
thank you so much. alot of the big ideas makes sense but learning the syntax is a long process
20th Jan 2018, 1:42 AM
david kerkel
david kerkel - avatar
0
Sorry. I just made it public.
20th Jan 2018, 12:58 AM
david kerkel
david kerkel - avatar