JulianJulianov

09.ObjectAndClasses-Advertisement Message

Mar 5th, 2020
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1. 09.ObjectAndClasses-Advertisement Message
  2. Write a program that generates random fake advertisement message to extol some product. The messages must consist of 4 parts: laudatory phrase + event + author + city. Use the following predefined parts:
  3. • Phrases – {"Excellent product.", "Such a great product.", "I always use that product.", "Best product of its category.", "Exceptional product.", "I can’t live without this product."}
  4. • Events – {"Now I feel good.", "I have succeeded with this product.", "Makes miracles. I am happy of the results!", "I cannot believe but now I feel awesome.", "Try it yourself, I am very satisfied.", "I feel great!"}
  5. • Authors – {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"}
  6. • Cities – {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"}
  7. The format of the output message is the following: {phrase} {event} {author}{city}.
  8. You will receive the number of messages to be generated. Print each random message at a separate line.
  9. Examples
  10. Input   Output//Random!!!
  11. 3       Such a great product. Now I feel good. Elena – Ruse
  12.         Excellent product. Makes miracles. I am happy of the results! Katya – Varna
  13.         Best product of its category. That makes miracles. Eva - Sofia
  14.  
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20.  
  21. namespace AdvertisementMessage
  22. {
  23.     class Program
  24.     {
  25.         static void Main(string[] args)
  26.         {
  27.             var phrases = new string[] { "Excellent product.", "Such a great product.", "I always use that product.", "Best product of its category.", "Exceptional product.", "I can’t live without this product." };
  28.             var events = new string[] { "Now I feel good.", "I have succeeded with this product.", "Makes miracles. I am happy of the results!", "I cannot believe but now I feel awesome.", "Try it yourself, I am very satisfied.", "I feel great!" };
  29.             var authors = new string[] { "Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva" };
  30.             var cities = new string[] { "Burgas", "Sofia", "Plovdiv", "Varna", "Ruse" };
  31.  
  32.             var sentenceRandom = new Random();
  33.          
  34.             var n = int.Parse(Console.ReadLine());
  35.             for (int i = 0; i < n; i++)
  36.             {
  37.                 int phraseIndex = sentenceRandom.Next(0, phrases.Length);
  38.                 int eventIndex = sentenceRandom.Next(0, events.Length);
  39.                 int authorIndex = sentenceRandom.Next(0, authors.Length);
  40.                 int citiesIndex = sentenceRandom.Next(0, cities.Length);
  41.                 Console.WriteLine($"{phrases[phraseIndex]} {events[eventIndex]} {authors[authorIndex]} - {cities[citiesIndex]}");
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment