C
C#7mo ago
js

✅ checking console input for certain letters

public override void Select()
{
Console.WriteLine("Please enter the customer's name.");
string CustomerName = Console.ReadLine();
Console.WriteLine("Is this order for delivery? ( Y / N )");
string forDelivery = Console.ReadLine();
void CheckInput(string input)
{
if (input != "Y" || input != "N")
{
Console.WriteLine("Invalid input! (Y or N)");
Console.WriteLine("Is this order for delivery? ( Y / N )");
forDelivery = Console.ReadLine();
CheckInput(forDelivery);
}
else if (input == "N" || input == "Y")
{
return;
}
}
CheckInput(forDelivery);

Order order = new Order(CustomerName, forDelivery);
_manager.AddOrder(order);
}
public override void Select()
{
Console.WriteLine("Please enter the customer's name.");
string CustomerName = Console.ReadLine();
Console.WriteLine("Is this order for delivery? ( Y / N )");
string forDelivery = Console.ReadLine();
void CheckInput(string input)
{
if (input != "Y" || input != "N")
{
Console.WriteLine("Invalid input! (Y or N)");
Console.WriteLine("Is this order for delivery? ( Y / N )");
forDelivery = Console.ReadLine();
CheckInput(forDelivery);
}
else if (input == "N" || input == "Y")
{
return;
}
}
CheckInput(forDelivery);

Order order = new Order(CustomerName, forDelivery);
_manager.AddOrder(order);
}
No description
3 Replies
js
jsOP7mo ago
no matter what i input im getting the invalid message even though Y or N is supposed to be valid input
daniel2
daniel27mo ago
Not Y OR not N Therefore if you enter Y, not N is true
js
jsOP7mo ago
oh so it should be anmd and thx
Want results from more Discord servers?
Add your server