Advertisement
Guest User

Untitled

a guest
Aug 17th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. /*Write a program that reads from the console a string of maximum 20 characters.
  2.  If the length of the string is less than 20, the rest of the characters should be filled with '*'.
  3.  Print the result string into the console.*/
  4. using System;
  5.  
  6. class StringNotBiggerThan20Characters
  7. {
  8.     static void Main()
  9.     {
  10.         Console.Write("Enter a string: ");
  11.         string text = Console.ReadLine();
  12.  
  13.         if (text.Length < 20)
  14.         {
  15.             for (int i = text.Length; i < 20; i++)
  16.             {
  17.                 text += '*';//I use += because the operations are too low to use StringBuilder and its fast
  18.             }
  19.         }
  20.         Console.WriteLine(text);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement