Let’s Create, .NET! Project ATM Part 4 – Write a loop for user input

Time to add our loop to maintain the console app running for input.

We also add a switch statement with a dummy case so we can accept different entries that will be our method calls.

  do
            {
                Console.WriteLine("WELCOME TO ATM 114");
                Console.WriteLine("********");
                Console.WriteLine("Add = add funds \nAccount = check balance\nWithdraw = Withdraw funds");

                Console.Write("Type action : ");
                string userinput = Console.ReadLine();

                switch (userinput)
                {
                    case "Add":
                        Console.WriteLine("Added!");
                        break;
                    
                    default:
                        
                        break;
                }
                Console.WriteLine("\nType exit to close the ATM or enter to continue.");

            } while (Console.ReadLine() != "quit");

Perfect! Now next time we’ll create our methods for our ATM.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: