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

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