Advertisement
desislava_topuzakova

Untitled

Jul 24th, 2022
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package Q.ObjectAndClassesEx;
  2.  
  3. import java.util.Random;
  4. import java.util.Scanner;
  5.  
  6. public class AdvertisementMessage {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. String[] phrases = {"Excellent product.", "Such a great product.", "I always use that product.",
  11. "Best product of its category.", "Exceptional product.", "I can’t live without this product."};
  12. String[] events = {"Now I feel good.", "I have succeeded with this product.",
  13. "Makes miracles. I am happy of the results!", "I cannot believe but now I feel awesome.",
  14. "Try it yourself, I am very satisfied.", "I feel great!"};
  15. String[] authors = {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"};
  16. String[] cities = {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"};
  17.  
  18. int numberOfMessages = Integer.parseInt(scanner.nextLine());
  19.  
  20. for (int i = 1; i <= numberOfMessages; i++) {
  21. Random random = new Random();
  22.  
  23. String phrase = phrases[random.nextInt(phrases.length)];
  24. String event = events[random.nextInt(events.length)];
  25. String author = authors[random.nextInt(authors.length)];
  26. String city = cities[random.nextInt(cities.length)];
  27.  
  28. System.out.printf("%s %s %s – %s%n", phrase, event, author, city);
  29. }
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement