Last active
April 21, 2025 11:38
-
-
Save Strelok78/1941a9771fdebb22dc89bcf76a1f5ea5 to your computer and use it in GitHub Desktop.
get symbol and name and return name in square of symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| namespace iJuniorPractice; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| string name; | |
| char symbol; | |
| string symbolLine = ""; | |
| string nameLine = ""; | |
| string enterSymbolMessage = "Enter symbol: "; | |
| string enterNameMessage = "Enter name: "; | |
| string enterErrorMessage = "Error: enter only one char."; | |
| string result; | |
| Console.Write(enterNameMessage); | |
| name = Console.ReadLine(); | |
| Console.Write(enterSymbolMessage); | |
| while (char.TryParse(Console.ReadLine(), out symbol) == false) | |
| { | |
| Console.WriteLine(enterErrorMessage); | |
| } | |
| nameLine = symbol + name + symbol; | |
| for (int i = 0; i < nameLine.Length; i++) | |
| { | |
| symbolLine += symbol; | |
| } | |
| result = symbolLine + "\n" + nameLine + "\n" + symbolLine; | |
| Console.WriteLine(result); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment