Advertisement
Guest User

Untitled

a guest
May 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. //Write a program that reads from the console a string of maximum 20 characters.If the length of the string is less than 20, the rest of the characters should be filled with*.
  2. namespace _06.String_length
  3. {
  4.     using System;
  5.     using System.Text;
  6.  
  7.     class StringLength
  8.     {
  9.         static void ModifyStr(string text)
  10.         {
  11.             StringBuilder input = new StringBuilder();
  12.             input.Append(text);
  13.             input= input.Replace("\\", string.Empty);
  14.             int lenght = input.Length;
  15.             int elseLenght = 0;
  16.  
  17.             if (lenght == 20)
  18.             {
  19.                 Console.WriteLine(input);
  20.             }
  21.             else
  22.             {
  23.                 elseLenght = 20 - lenght;
  24.                 input.Append('*', elseLenght);
  25.                 Console.WriteLine(input);
  26.             }
  27.         }
  28.  
  29.         static void Main()
  30.         {
  31.             string input = Console.ReadLine();
  32.             input = input.Replace(@"\", string.Empty);
  33.             Console.WriteLine(input.PadRight(20, '*'));
  34.  
  35.             // ModifyStr(input);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement