In: Computer Science
Write a C# console program that continually asks the user "Do you want to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and then get keyboard input of the name. After entering the name, display the name to the screen.
using System;
public class Test
{
public static void Main()
{
string option, name;
do //loop to ask first and last name
{
Console.WriteLine("Enter your first and last name: ");
name = Console.ReadLine();
Console.WriteLine("Your name is: " + name);
Console.WriteLine("Do you want to enter another name (Y/N)
?");
option = Console.ReadLine();
} while (option == "Y" || option == "y");
}
}
==============================================
SEE OUTPUT
==========================================================================
Thanks, let me know if you need more information. PLEASE COMMENT if there is any concern.