In my while loop it prompts the user to enter a value and once value is entered operates certain methods. The problem I am having is that the user is prompted to enter the value twice (i.e. asks to enter A, B or X. User enters value then program asks again to enter A,B or X without performing the correct operation). Any help to have it operate after being entered would be great!
class output
{
static void Main(string[] args)
{
char userInput;
char upper;
Accounts myAccounts = new Accounts();
myAccounts.input();
Console.WriteLine("Enter an A to search account numbers");
Console.WriteLine("Enter a B to average the accounts");
Console.WriteLine("Enter X to quit the program");
Console.WriteLine("Enter an option --->");
userInput = Convert.ToChar(Console.ReadLine());
upper = char.ToUpper(userInput);
while (upper != 'X')
{
if (upper == 'A')
{
myAccounts.search();
Console.WriteLine("Enter an A to search account numbers");
Console.WriteLine("Enter a B to average the accounts");
Console.WriteLine("Enter X to quit the program");
Console.WriteLine("Enter an option --->");
userInput = Convert.ToChar(Console.ReadLine());
upper = char.ToUpper(userInput);
}
else if (upper == 'B')
{
myAccounts.average();
Console.WriteLine("Enter an A to search account numbers");
Console.WriteLine("Enter a B to average the accounts");
Console.WriteLine("Enter X to quit the program");
Console.WriteLine("Enter an option --->");
userInput = Convert.ToChar(Console.ReadLine());
upper = char.ToUpper(userInput);
}
else
Console.WriteLine("You entered an incorrect option, please select new option");
Console.WriteLine("Enter an A to search account numbers");
Console.WriteLine("Enter a B to average the accounts");
Console.WriteLine("Enter X to quit the program");
Console.WriteLine("Enter an option --->");
userInput = Convert.ToChar(Console.ReadLine());
upper = char.ToUpper(userInput);
}
}
}
PrintMenu()EvalInput(char input)etc..