Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // Short program made in C# that ramdomize a phrase you input between lower case and uppercase.
  2.  
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Randomizer
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {//declaring variables
  16. string userInput;
  17.  
  18.  
  19. //Printing text and storing user input in variable.
  20. Console.WriteLine("Please introduce a sentence to randomize");
  21. userInput = Console.ReadLine();
  22.  
  23. //Ramdomize user's input
  24. for (int i = 0; i < userInput.Length; i++)
  25. {
  26. Random rnd = new Random();
  27. int coinFlip = rnd.Next(2);
  28.  
  29.  
  30. if (coinFlip == 0)
  31. {
  32. //Print user's new randomized input
  33. Console.WriteLine($"{userInput.ToUpper()[i]}");
  34. }
  35.  
  36. else if (coinFlip == 1)
  37. {
  38. //Print user's new randomized input
  39. Console.WriteLine($"{userInput.ToLower()[i]}");
  40. }
  41.  
  42.  
  43.  
  44. }
  45. Console.ReadLine();
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement