+ 1

Help! Why doesn't it work?

Why doesn't it work? https://code.sololearn.com/ccwOG2TyE73d/?ref=app

6th Dec 2017, 3:58 PM
EWan
EWan - avatar
4 Answers
+ 1
Age should be int instead of string. You need to parse your readline as an int. In the last 'else' you need to either make it an 'else if' or remove the condition. If I remember right, that were your errors. https://code.sololearn.com/cmeqk0H2i5cd/#cs int age; Console.WriteLine("How old are you?"); age = Convert.ToInt32(Console.ReadLine()); if (age<=10) { Console.WriteLine("You are child"); } else if (age<=16) { Console.WriteLine("You are teenager"); } else if (age<=20) { Console.WriteLine("You are adult"); } else { Console.WriteLine("YOU ARE OLD"); }
6th Dec 2017, 4:10 PM
AgentSmith
+ 1
Thanks)
6th Dec 2017, 4:21 PM
EWan
EWan - avatar
+ 1
You're welcome.
6th Dec 2017, 4:22 PM
AgentSmith
+ 1
I have a question Why 'int' and not 'string'?
7th Dec 2017, 2:06 AM
EWan
EWan - avatar