0

where did i go wrong ?

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) { int age = Convert.ToInt32(Console.ReadLine());; if ( age >= 18) { Console.WriteLine("Too young"); } else if( age >= 30) { Console.WriteLine("You still poor"); } else if( age >= 50) { Console.WriteLine(" You ve got the money now "); } } } } https://code.sololearn.com/cv7cL117F5jO/?ref=app //output is always too young

26th Mar 2019, 9:29 AM
Kappu
Kappu - avatar
5 Réponses
26th Mar 2019, 9:52 AM
Kappu
Kappu - avatar
+ 11
Give priority to posting a link to the code rather than posting the whole question here. It will help us debug your program
26th Mar 2019, 9:33 AM
Letsintegreat
Letsintegreat - avatar
+ 5
Hey what do you expect the output? Suppose I enter age 70 it is >18 so only first if will get executed ...Everytime ..Your logic in this code is flawed..
26th Mar 2019, 9:32 AM
Saksham Jain
Saksham Jain - avatar
+ 1
i've posted the link
26th Mar 2019, 9:38 AM
Kappu
Kappu - avatar
+ 1
Interesting. If the order of logic results is reverse, 50 and its result first, does this fix the problem?
26th Mar 2019, 11:08 AM
Michael Williams
Michael Williams - avatar