desislava_topuzakova

01. Advertisement Message

Oct 30th, 2021
1,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. package ObjectsAndClasses.AdvertismentMessage;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.  
  11.         Message message = new Message();
  12.  
  13.         for (int i = 0; i < n; i++) {
  14.             message.randomMessage();
  15.         }
  16.     }
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. package ObjectsAndClasses.AdvertismentMessage;
  25.  
  26.  
  27. import java.util.Random;
  28.  
  29. public class Message {
  30.     public String[] 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."};
  31.     public String[] 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!"};
  32.     public String[] authors = {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"};
  33.     public String[] cities = {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"};
  34.  
  35.     Random random = new Random();
  36.  
  37.     public void randomMessage() {
  38.         System.out.printf("%s %s %s - %s."
  39.                 , phrases[random.nextInt(phrases.length)]
  40.                 , events[random.nextInt(events.length)]
  41.                 , authors[random.nextInt(authors.length)]
  42.                 , cities[random.nextInt(cities.length)]);
  43.  
  44.         System.out.println();
  45.     }
  46.  
  47.  
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment