0

using System; namespace Project { class MyClass { public static void Main(string[] args) { int age; string name;

string answer = "Fine"; string answer1 = "fine"; Console.WriteLine("What is your name"); name = Convert.ToString(Console.ReadLine()); Console.WriteLine("Hey..." + name); Console.WriteLine("How are you doing today"); answer = Convert.ToString(Console.ReadLine()); answer1 = Convert.ToString(Console.ReadLine()); if (answer1 == fine){ Console.WriteLine("Nice hearing that"); } else { Console.WriteLine("Sorry for whatever happened"); Console.WriteLine("I hope it would be fine!"); } if (answer == Fine) { Console.WriteLine("Nice!"); } else { Console.WriteLine("Sorry, I hope it would be fine"); } age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How old are you" + name); Console.ReadKey(); if (age < 18) { Console.WriteLine("Sorry" + name + "You are not old enough"); } else if (age == 18) { Console.WriteLine("You are still allowed" + name); } else { Console.WriteLine("You are allowed"+ name)

5th Oct 2021, 10:16 AM
omitogun toni
omitogun toni - avatar
1 Resposta
0
Ok so your problem is that when you do comparison with Fine and fine you did not put that as a string literal. If you compare variable with the string you must do this like this: variable_name = "some string value"
5th Oct 2021, 9:29 PM
Piotr
Piotr - avatar